shared-macros.mk: define USE_CTF to enable CTF
CTF is the "Compact Type Format", a compressed debugging metadata
format used by dtrace and mdb. Most of illumos-gate is built with
CTF; it would be helpful for observability if a few other packages
from userland were also built with CTF.
| | |
| | | $(MKDIR) $@ |
| | | |
| | | PKGMANGLE_OPTIONS = -D $(MANGLED_DIR) $(PKG_PROTO_DIRS:%=-d %) |
| | | ifeq ($(strip $(USE_CTF)),yes) |
| | | PKGMANGLE_OPTIONS += -c $(CTFCONVERT) |
| | | endif |
| | | $(MANIFEST_BASE)-%.mangled: $(MANIFEST_BASE)-%.mogrified $(MANGLED_DIR) |
| | | $(PKGMANGLE) $(PKGMANGLE_OPTIONS) -m $< >$@ |
| | | |
| | |
| | | DOS2UNIX = /usr/bin/dos2unix |
| | | TAC = /usr/bin/tac |
| | | QUILT = /usr/bin/quilt |
| | | CTFCONVERT = /opt/onbld/bin/$(MACH)/ctfconvert |
| | | |
| | | INS.dir= $(INSTALL) -d $@ |
| | | INS.file= $(INSTALL) -m 444 $< $(@D) |
| | |
| | | # Add compiler specific 'default' features |
| | | CFLAGS += $(CFLAGS.$(COMPILER)) |
| | | |
| | | # Per-compiler CFLAGS to use when building for CTF. Currently only defined |
| | | # for gcc; could be made to work with other compilers. |
| | | |
| | | # -gdwarf-4 is the newest DWARF revision understood by illumos libctf |
| | | # |
| | | # -gstrict-dwarf prevents the compiler from including newer DWARF features |
| | | CTF_CFLAGS.gcc = -g -gdwarf-4 -gstrict-dwarf |
| | | # -msave-args makes it possible for debugging tools (specifically pstack and |
| | | # mdb) to retrieve function arguments, and is required for the python pstack |
| | | # hooks. |
| | | CTF_CFLAGS.gcc += -msave-args |
| | | # By default, GCC may put parts of functions in different named sub-sections |
| | | # of .text based on their presumed or measured calling frequency. This is not |
| | | # currently handled by libctf and other illumos tools which assume that a |
| | | # function's text lies in a single contiguous range of virtual addresses. |
| | | # Disable this optimization if building with CTF. |
| | | CTF_CFLAGS.gcc += -fno-reorder-functions -fno-reorder-blocks-and-partition |
| | | |
| | | # Enable CTF if desired |
| | | ifeq ($(strip $(USE_CTF)),yes) |
| | | CFLAGS += $(if $(CTF_CFLAGS.$(COMPILER)), \ |
| | | $(CTF_CFLAGS.$(COMPILER)), \ |
| | | $(error Error: CTF_CFLAGS.$(COMPILER) must be defined to use CTF with $(COMPILER))) |
| | | endif |
| | | |
| | | # Build 32 or 64 bit objects in C++ as well. |
| | | CXXFLAGS += $(CC_BITS) |
| | | |
| | |
| | | re.MULTILINE|re.DOTALL) |
| | | return cddl_re.sub('', text) |
| | | |
| | | def mangle_path(manifest, action, src, dest): |
| | | def do_ctfconvert(converter, file): |
| | | args = [converter, '-i', '-m', '-k', file] |
| | | print(*args, file=sys.stderr) |
| | | subprocess.call(args) |
| | | |
| | | def mangle_path(manifest, action, src, dest, ctfconvert): |
| | | if elf.is_elf_object(src): |
| | | if ctfconvert is not None: |
| | | do_ctfconvert(ctfconvert, src) |
| | | mangle_elf(manifest, action, src, dest) |
| | | else: |
| | | # a 'text' document (script, man page, config file, ... |
| | |
| | | # |
| | | # mangler.bypass = (true|false) |
| | | # |
| | | def mangle_paths(manifest, search_paths, destination): |
| | | def mangle_paths(manifest, search_paths, destination, ctfconvert): |
| | | for action in manifest.gen_actions_by_type("file"): |
| | | bypass = action.attrs.pop('mangler.bypass', 'false').lower() |
| | | if bypass == 'true': |
| | |
| | | if directory != destination: |
| | | src = os.path.join(directory, path) |
| | | if os.path.isfile(src): |
| | | mangle_path(manifest, action, src, dest) |
| | | mangle_path(manifest, action, |
| | | src, dest, ctfconvert) |
| | | break |
| | | |
| | | def load_manifest(manifest_file): |
| | |
| | | search_paths = [] |
| | | destination = None |
| | | manifests = [] |
| | | ctfconvert = None |
| | | |
| | | try: |
| | | opts, args = getopt.getopt(sys.argv[1:], "D:d:m:", |
| | | ["destination=", "search-directory=", "manifest="]) |
| | | opts, args = getopt.getopt(sys.argv[1:], "c:D:d:m:", |
| | | ["ctf=", "destination=", "search-directory=", "manifest="]) |
| | | except getopt.GetoptError as err: |
| | | print(str(err)) |
| | | usage() |
| | |
| | | usage() |
| | | else: |
| | | manifests.append(manifest) |
| | | elif opt in [ "-c", "--ctf" ]: |
| | | ctfconvert = arg |
| | | else: |
| | | usage() |
| | | |
| | |
| | | usage() |
| | | |
| | | for manifest in manifests: |
| | | mangle_paths(manifest, search_paths, destination) |
| | | mangle_paths(manifest, search_paths, destination, ctfconvert) |
| | | print(manifest) |
| | | |
| | | sys.exit(0) |