diff --git a/Programming/cctools/build b/Programming/cctools/build new file mode 100755 index 0000000..b280e4b --- /dev/null +++ b/Programming/cctools/build @@ -0,0 +1,26 @@ +#!/usr/bin/env modbuild +# +# :FIXME: this is work in progress! +# +pbuild::add_to_group 'Programming' +pbuild::set_download_url "https://opensource.apple.com/tarballs/cctools/$P-$V.tar.gz" +pbuild::compile_in_sourcetree + +pbuild::set_default_patch_strip 0 +pbuild::add_patch 'files/PR-12400897.patch' +pbuild::add_patch 'files/PR-37520.patch' +pbuild::add_patch 'files/cctools-829-lto.patch' +pbuild::add_patch 'files/cctools-839-static-dis_info.patch' +pbuild::add_patch 'files/cctools-862-prunetrie.patch' +pbuild::add_patch 'files/cctools-895-OFILE_LLVM_BITCODE.patch' +pbuild::add_patch 'files/cctools-895-big_endian.patch' +pbuild::add_patch 'files/not-clang.patch' + +#pbuild::set_docfiles 'COPYING' 'COPYING.LIB' 'COPYING.RUNTIME' 'COPYING3' 'COPYING3.LIB' 'NEWS' 'README' + +pbuild::configure() { + : +} + +pbuild::make_all + diff --git a/Programming/cctools/files/PR-12400897.patch b/Programming/cctools/files/PR-12400897.patch new file mode 100644 index 0000000..8a2ac50 --- /dev/null +++ b/Programming/cctools/files/PR-12400897.patch @@ -0,0 +1,35 @@ +--- misc/nm.c 1969-12-31 16:00:00.000000000 -0800 ++++ misc/nm.c 2012-09-29 12:36:22.000000000 -0700 +@@ -496,7 +496,7 @@ void *cookie) + uint32_t nsymbols; + struct value_diff *value_diffs; + +- char *short_name, *has_suffix; ++ char *short_name, *suffix; + enum bool is_framework; + + cmd_flags = (struct cmd_flags *)cookie; +@@ -650,9 +650,20 @@ void *cookie) + process_flags.lib_names[j] = + (char *)dl + dl->dylib.name.offset; + short_name = guess_short_name(process_flags.lib_names[j], +- &is_framework, &has_suffix); +- if(short_name != NULL) +- process_flags.lib_names[j] = short_name; ++ &is_framework, &suffix); ++ if(short_name != NULL) { ++ if (suffix) { ++ char *combined_name; ++ asprintf(&combined_name, "%s%s", short_name, suffix); ++ if (combined_name) { ++ process_flags.lib_names[j] = combined_name; ++ free(short_name); ++ free(suffix); ++ } ++ } else { ++ process_flags.lib_names[j] = short_name; ++ } ++ } + j++; + } + lc = (struct load_command *) diff --git a/Programming/cctools/files/PR-37520.patch b/Programming/cctools/files/PR-37520.patch new file mode 100644 index 0000000..fcac838 --- /dev/null +++ b/Programming/cctools/files/PR-37520.patch @@ -0,0 +1,55 @@ +--- as/ppc.c.orig 2013-01-04 10:39:49.000000000 +0100 ++++ as/ppc.c 2013-01-04 10:40:02.000000000 +0100 +@@ -1019,6 +1019,8 @@ char *op) + + /* if this instruction requires labels mark it for later */ + switch(insn.reloc){ ++ case NO_RELOC: ++ break; + case PPC_RELOC_HI16: + case PPC_RELOC_LO16: + case PPC_RELOC_HA16: +@@ -1033,6 +1035,7 @@ char *op) + insn.reloc); + break; + case PPC_RELOC_BR14: ++ case PPC_RELOC_BR14_predicted: + fix_new(frag_now, + thisfrag - frag_now->fr_literal, + 4, +--- as/m88k.c.orig 1969-12-31 16:00:00.000000000 -0800 ++++ as/m88k.c 2013-07-05 10:32:19.000000000 -0700 +@@ -600,6 +600,10 @@ char *op) + + /* if this instruction requires labels mark it for later */ + switch (insn.reloc) { ++ ++ case NO_RELOC: ++ break; ++ + case M88K_RELOC_LO16: + case M88K_RELOC_HI16: + fix_new( +--- as/sparc.c.orig 1969-12-31 16:00:00.000000000 -0800 ++++ as/sparc.c 2013-07-05 10:32:14.000000000 -0700 +@@ -851,6 +851,20 @@ sparc_ip (str) + /* plug absolutes directly into opcode */ + + switch(the_insn.reloc) { ++ case SPARC_RELOC_13: ++ if (the_insn.exp.X_seg == SEG_BIG) ++ opcode |= (*(int *) generic_bignum) & 0x1fff; ++ else ++ opcode |= the_insn.exp.X_add_number & 0x1fff; ++ the_insn.reloc = SPARC_RELOC_NONE; ++ break; ++ case SPARC_RELOC_22: ++ if (the_insn.exp.X_seg == SEG_BIG) ++ opcode |= (*(int *) generic_bignum) & 0x3fffff; ++ else ++ opcode |= the_insn.exp.X_add_number & 0x3fffff; ++ the_insn.reloc = SPARC_RELOC_NONE; ++ break; + case SPARC_RELOC_HI22: + /* extract upper 22 bits from constant */ + opcode |= (the_insn.exp.X_add_number >> 10) & 0x3fffff; diff --git a/Programming/cctools/files/cctools-829-lto.patch b/Programming/cctools/files/cctools-829-lto.patch new file mode 100644 index 0000000..79c811a --- /dev/null +++ b/Programming/cctools/files/cctools-829-lto.patch @@ -0,0 +1,39 @@ +--- libstuff/lto.c.orig 1969-12-31 16:00:00.000000000 -0800 ++++ libstuff/lto.c 2012-09-04 14:59:31.000000000 -0700 +@@ -112,13 +112,21 @@ void **pmod) /* maybe NULL */ + lto_path = makestr(prefix, "../lib/libLTO.dylib", NULL); + + lto_handle = dlopen(lto_path, RTLD_NOW); ++ free(lto_path); ++ lto_path = NULL; + if(lto_handle == NULL){ +- free(lto_path); +- lto_path = NULL; +- lto_handle = dlopen("/Applications/Xcode.app/Contents/" +- "Developer/Toolchains/XcodeDefault." +- "xctoolchain/usr/lib/libLTO.dylib", +- RTLD_NOW); ++ const char *lto_paths[] = { ++ "@@LLVM_LIBDIR@@/libLTO.dylib", ++ "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/libLTO.dylib", ++ "/usr/lib/libLTO.dylib", ++ "/Applications/Xcode.app/usr/lib/libLTO.dylib", ++ "/Developer/usr/lib/libLTO.dylib", ++ NULL ++ }; ++ const char **p; ++ for(p = lto_paths; *p && !lto_handle ; p++) { ++ lto_handle = dlopen(*p, RTLD_NOW); ++ } + } + if(lto_handle == NULL) + return(0); +@@ -142,8 +150,6 @@ void **pmod) /* maybe NULL */ + lto_get_sym_attr == NULL || + lto_get_sym_name == NULL){ + dlclose(lto_handle); +- if(lto_path != NULL) +- free(lto_path); + return(0); + } + } diff --git a/Programming/cctools/files/cctools-839-static-dis_info.patch b/Programming/cctools/files/cctools-839-static-dis_info.patch new file mode 100644 index 0000000..3a490ce --- /dev/null +++ b/Programming/cctools/files/cctools-839-static-dis_info.patch @@ -0,0 +1,22 @@ +--- otool/arm_disasm.c.orig 2013-08-29 14:23:24.000000000 -0700 ++++ otool/arm_disasm.c 2013-08-29 14:23:51.000000000 -0700 +@@ -62,7 +62,7 @@ typedef char bfd_byte; + + /* HACKS to avoid pulling in all of FSF binutils include/dis-asm.h */ + typedef int (*fprintf_ftype) (void *, const char*, ...); +-struct disassemble_info { /* HACK'ed up for just what we need here */ ++static struct disassemble_info { /* HACK'ed up for just what we need here */ + fprintf_ftype fprintf_func; + void *stream; + +--- otool/i386_disasm.c.orig 2013-08-29 14:23:19.000000000 -0700 ++++ otool/i386_disasm.c 2013-08-29 14:24:00.000000000 -0700 +@@ -1600,7 +1600,7 @@ static unsigned int xmm_rm(int r_m, int + /* + * This is passed to the llvm disassembler. + */ +-struct disassemble_info { ++static struct disassemble_info { + enum bool verbose; + /* Relocation information. */ + struct relocation_info *sorted_relocs; diff --git a/Programming/cctools/files/cctools-862-prunetrie.patch b/Programming/cctools/files/cctools-862-prunetrie.patch new file mode 100644 index 0000000..ebe7d9a --- /dev/null +++ b/Programming/cctools/files/cctools-862-prunetrie.patch @@ -0,0 +1,34 @@ +--- misc/Makefile.orig 2015-01-10 20:43:30.000000000 -0800 ++++ misc/Makefile 2015-01-10 20:51:27.000000000 -0800 +@@ -201,14 +201,18 @@ indr.NEW: indr.o + $(OFILE_DIR)/indr.private.o + $(DSYMUTIL) $(SYMROOT)/indr.NEW + +-strip.NEW: strip.o ++strip.NEW: strip.o PruneTrie.o + $(CC) $(RC_CFLAGS) -nostdlib -r \ + -o $(OBJROOT)/strip.private.o \ + $(OFILE_DIR)/strip.o $(LIBSTUFF) + $(CXX) $(RC_CFLAGS) $(SDK) -o $(SYMROOT)/strip.NEW \ +- $(OFILE_DIR)/strip.private.o $(LIB_PRUNETRIE) $(CXXLIB) ++ $(OFILE_DIR)/strip.private.o $(OFILE_DIR)/PruneTrie.o $(CXXLIB) + $(DSYMUTIL) $(SYMROOT)/strip.NEW + ++PruneTrie.o: PruneTrie.cpp ++ $(CXX) $(CXXFLAGS) $(RC_CFLAGS) $(SDK) $(CXXLIB) -c -o \ ++ $(OBJROOT)/PruneTrie.o $(SRCROOT)/PruneTrie.cpp ++ + nmedit.NEW: nmedit.o + $(CC) $(RC_CFLAGS) -nostdlib -r \ + -o $(OBJROOT)/nmedit.private.o \ +--- misc/strip.c.orig 2015-01-10 21:25:17.000000000 -0800 ++++ misc/strip.c 2015-01-10 21:25:40.000000000 -0800 +@@ -47,7 +47,7 @@ + #include "stuff/unix_standard_mode.h" + #include "stuff/execute.h" + #ifdef TRIE_SUPPORT +-#include ++#include "prune_trie.h" + #endif /* TRIE_SUPPORT */ + + /* These are set from the command line arguments */ diff --git a/Programming/cctools/files/cctools-895-OFILE_LLVM_BITCODE.patch b/Programming/cctools/files/cctools-895-OFILE_LLVM_BITCODE.patch new file mode 100644 index 0000000..c137e4c --- /dev/null +++ b/Programming/cctools/files/cctools-895-OFILE_LLVM_BITCODE.patch @@ -0,0 +1,18 @@ +--- misc/strings.c-orig 2016-12-09 19:03:02.000000000 +0100 ++++ misc/strings.c 2016-12-23 10:35:34.000000000 +0100 +@@ -335,8 +335,13 @@ + * If the ofile is not an object file then process it without reguard + * to sections. + */ +- if(ofile->object_addr == NULL || ofile->member_type == OFILE_LLVM_BITCODE){ +- if(ofile->file_type == OFILE_FAT && ofile->arch_flag.cputype != 0){ ++ if(ofile->object_addr == NULL ++#ifdef LTO_SUPPORT ++ || ofile->member_type == OFILE_LLVM_BITCODE){ ++#else ++ ){ ++#endif /* LTO_SUPPORT */ ++ if(ofile->file_type == OFILE_FAT && ofile->arch_flag.cputype != 0){ + if(ofile->fat_header->magic == FAT_MAGIC_64){ + addr = ofile->file_addr + + ofile->fat_archs64[ofile->narch].offset; diff --git a/Programming/cctools/files/cctools-895-big_endian.patch b/Programming/cctools/files/cctools-895-big_endian.patch new file mode 100644 index 0000000..92aa091 --- /dev/null +++ b/Programming/cctools/files/cctools-895-big_endian.patch @@ -0,0 +1,12 @@ +--- libstuff/ofile.c- 2016-12-16 11:53:10.000000000 -0500 ++++ libstuff/ofile.c 2016-12-16 11:53:41.000000000 -0500 +@@ -3423,7 +3423,7 @@ + if(size - offset > sizeof(uint32_t)){ + memcpy(&magic, addr + offset, sizeof(uint32_t)); + #ifdef __BIG_ENDIAN__ +- if(magic == FAT_MAGIC || (magic == FAT_MAGIC_64) ++ if(magic == FAT_MAGIC || magic == FAT_MAGIC_64) + #endif /* __BIG_ENDIAN__ */ + #ifdef __LITTLE_ENDIAN__ + if(magic == SWAP_INT(FAT_MAGIC) || + diff --git a/Programming/cctools/files/not-clang.patch b/Programming/cctools/files/not-clang.patch new file mode 100644 index 0000000..6db44a2 --- /dev/null +++ b/Programming/cctools/files/not-clang.patch @@ -0,0 +1,12 @@ +--- as/driver.c.orig 2015-11-23 21:01:45.000000000 -0800 ++++ as/driver.c 2015-11-23 21:09:24.000000000 -0800 +@@ -280,6 +280,9 @@ char **envp) + arch_flag.cputype == CPU_TYPE_ARM) + run_clang = 1; + ++ /* MACPORTS: Don't use the clang assembler for now. */ ++ run_clang = 0; ++ + /* + * Use the clang as the assembler if is the default or asked to with + * the -q flag. But don't use it asked to use the system assembler diff --git a/Programming/cctools/files/snowleopard-strnlen.patch b/Programming/cctools/files/snowleopard-strnlen.patch new file mode 100644 index 0000000..80e3b82 --- /dev/null +++ b/Programming/cctools/files/snowleopard-strnlen.patch @@ -0,0 +1,21 @@ +--- otool/ofile_print.c.orig 2013-11-10 22:33:14.000000000 -0800 ++++ otool/ofile_print.c 2013-11-10 22:34:19.000000000 -0800 +@@ -225,6 +225,18 @@ + #include "stuff/guess_short_name.h" + #include "ofile_print.h" + ++static size_t ++strnlen(const char *s, size_t maxlen) ++{ ++ size_t len; ++ ++ for (len = 0; len < maxlen; len++, s++) { ++ if (!*s) ++ break; ++ } ++ return (len); ++} ++ + /* */ + /* The maximum section alignment allowed to be specified, as a power of two */ + #define MAXSECTALIGN 15 /* 2**15 or 0x8000 */ diff --git a/Programming/cctools/files/variants b/Programming/cctools/files/variants new file mode 100644 index 0000000..1bfef38 --- /dev/null +++ b/Programming/cctools/files/variants @@ -0,0 +1 @@ +ctools/895 unstable