From 0a219dff8fceaf496c307cf83a0a345070f35e82 Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Tue, 3 Sep 2019 19:06:03 +0200 Subject: [PATCH] LDC: Upgrade from v1.13 to v1.17 (#4246) * LDC: Upgrade from v1.13 to v1.17 * LDC: Fix missing symbols in druntime's core.sys.posix.unistd * LDC: Fix repeated llvm-config help output * LDC: Revise build script 1) Use an 'installed' (ninja install) LLVM for LDC. 2) Cross-compile LLVM before invoking CMake for LDC, so that the LLVM dir is actually populated (previously: just fake bin/llvm-config). 3) Include dlang tools ddemangle and dustmite in the final package too, just like official LDC packages. Cmdline flags have been synced with upstream. * Add hello-world smoke test * LDC: Upgrade LLVM from v7.0.1 to v8.0.1 --- packages/ldc/build.sh | 96 +++++++---- packages/ldc/ldc-druntime-link-symbols.patch | 6 +- packages/ldc/ldc-druntime-unistd.patch | 170 +++++++++++++++++++ packages/ldc/ldc-x64-sprintf.patch | 55 +++--- packages/ldc/llvm-config.in | 81 ++++----- packages/ldc/tests/hello_world.sh | 8 + 6 files changed, 309 insertions(+), 107 deletions(-) create mode 100644 packages/ldc/ldc-druntime-unistd.patch create mode 100755 packages/ldc/tests/hello_world.sh diff --git a/packages/ldc/build.sh b/packages/ldc/build.sh index ccd85cc5f..d6eb7756b 100644 --- a/packages/ldc/build.sh +++ b/packages/ldc/build.sh @@ -1,23 +1,24 @@ +LLVM_INSTALL_DIR=$TERMUX_PKG_BUILDDIR/llvm-install + TERMUX_PKG_HOMEPAGE=https://github.com/ldc-developers/ldc TERMUX_PKG_DESCRIPTION="D programming language compiler, built with LLVM" TERMUX_PKG_LICENSE="BSD 3-Clause" TERMUX_PKG_VERSION=() -TERMUX_PKG_VERSION+=(1.13.0) -TERMUX_PKG_VERSION+=(7.0.1) # LLVM version -TERMUX_PKG_VERSION+=(2.083.1) # TOOLS version -TERMUX_PKG_VERSION+=(1.12.1) # DUB version -TERMUX_PKG_REVISION=4 +TERMUX_PKG_VERSION+=(1.17.0) +TERMUX_PKG_VERSION+=(8.0.1) # LLVM version +TERMUX_PKG_VERSION+=(2.087.1) # TOOLS version +TERMUX_PKG_VERSION+=(1.16.0) # DUB version TERMUX_PKG_SRCURL=(https://github.com/ldc-developers/ldc/releases/download/v${TERMUX_PKG_VERSION}/ldc-${TERMUX_PKG_VERSION}-src.tar.gz https://github.com/ldc-developers/llvm/releases/download/ldc-v${TERMUX_PKG_VERSION[1]}/llvm-${TERMUX_PKG_VERSION[1]}.src.tar.xz https://github.com/dlang/tools/archive/v${TERMUX_PKG_VERSION[2]}.tar.gz https://github.com/dlang/dub/archive/v${TERMUX_PKG_VERSION[3]}.tar.gz https://github.com/ldc-developers/ldc/releases/download/v${TERMUX_PKG_VERSION}/ldc2-${TERMUX_PKG_VERSION}-linux-x86_64.tar.xz) -TERMUX_PKG_SHA256=(4b2fd3eb90fb6debc0ae6d70406bc78fcb531a0f20806640e626d4822e87b2e0 - 5b01afd896b534f4d6a0ff0073d9f1b09625b37b0a752259a1caf857c56c0fc3 - 78d90dcda6b82d3eda69c30fa2308a8c8f1a3bce574d637806ca1af3c7f65888 - bd17cf67784f2ea0a2e0298761c662c80fddf6700c065f6689eb353e2144c987 - 3692974b6dc6c81280c0321371b400101006f28bafb890f089b1d357dadbcbf1) +TERMUX_PKG_SHA256=(6a2fa91a53d954361832591488241c92adb497842069077425d73c9b9d2c4fa9 + af469483241e90366f910af32ca3a23e878ad8d2f29c0518811da19e1b6f4454 + a7cb8b217f2841f1ebe513ac5090d6ef77e03dc72bf2047bf92632c263941810 + f4291dc053864b81c10dc1e9f9220aee3d4ce7ef735ecdb70de9ecbf6e0aaa5b + 715adbdd614edf926d5f53bb9f8bfa34d0c828aa40077cb627ce064955fd641d) TERMUX_PKG_DEPENDS="clang, libc++, zlib" TERMUX_PKG_NO_STATICSPLIT=true TERMUX_PKG_HOSTBUILD=true @@ -27,8 +28,14 @@ TERMUX_PKG_EXTRA_CONFIGURE_ARGS=" -DLLVM_ENABLE_PIC=ON -DLLVM_BUILD_TOOLS=OFF -DLLVM_BUILD_UTILS=OFF +-DCOMPILER_RT_INCLUDE_TESTS=OFF +-DLLVM_ENABLE_TERMINFO=OFF +-DLLVM_ENABLE_LIBEDIT=OFF -DLLVM_TABLEGEN=$TERMUX_PKG_HOSTBUILD_DIR/bin/llvm-tblgen -DPYTHON_EXECUTABLE=$(which python3) +-DLLVM_TARGETS_TO_BUILD='AArch64;ARM;X86' +-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly +-DCMAKE_INSTALL_PREFIX=$LLVM_INSTALL_DIR " termux_step_post_extract_package() { @@ -39,30 +46,34 @@ termux_step_post_extract_package() { fi mv llvm-${TERMUX_PKG_VERSION[1]}.src llvm - mv tools-${TERMUX_PKG_VERSION[2]} rdmd + mv tools-${TERMUX_PKG_VERSION[2]} dlang-tools mv dub-${TERMUX_PKG_VERSION[3]} dub export LLVM_TRIPLE=${TERMUX_HOST_PLATFORM/-/--} if [ $TERMUX_ARCH = arm ]; then LLVM_TRIPLE=${LLVM_TRIPLE/arm-/armv7a-}; fi sed $TERMUX_PKG_BUILDER_DIR/llvm-config.in \ -e "s|@LLVM_VERSION@|${TERMUX_PKG_VERSION[1]}|g" \ - -e "s|@LLVM_BUILD_DIR@|$TERMUX_PKG_BUILDDIR/llvm|g" \ + -e "s|@LLVM_INSTALL_DIR@|$LLVM_INSTALL_DIR|g" \ -e "s|@TERMUX_PKG_SRCDIR@|$TERMUX_PKG_SRCDIR|g" \ -e "s|@LLVM_DEFAULT_TARGET_TRIPLE@|$LLVM_TRIPLE|g" \ - -e "s|@LLVM_TARGETS@|ARM AArch64 X86|g" > $TERMUX_PKG_BUILDDIR/llvm-config + -e "s|@LLVM_TARGETS@|AArch64 ARM X86 WebAssembly|g" > $TERMUX_PKG_BUILDDIR/llvm-config chmod 755 $TERMUX_PKG_BUILDDIR/llvm-config } termux_step_host_build() { termux_setup_cmake termux_setup_ninja + + # Build native llvm-tblgen, a prerequisite for cross-compiling LLVM cmake -GNinja $TERMUX_PKG_SRCDIR/llvm \ + -DCMAKE_BUILD_TYPE=Release \ -DLLVM_BUILD_TOOLS=OFF \ -DLLVM_BUILD_UTILS=OFF \ -DCOMPILER_RT_INCLUDE_TESTS=OFF ninja -j $TERMUX_MAKE_PROCESSES llvm-tblgen } +# Just before CMake invokation for LLVM: termux_step_pre_configure() { LDFLAGS+=" -lc++_shared" @@ -71,15 +82,18 @@ termux_step_pre_configure() { LLVM_TARGET_ARCH=ARM elif [ $TERMUX_ARCH = "aarch64" ]; then LLVM_TARGET_ARCH=AArch64 + # LLVM 8.0.1's libclang_rt.hwasan-*-android.so fails to link for AArch64 and x86_64 + TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" -DCOMPILER_RT_BUILD_SANITIZERS=OFF" elif [ $TERMUX_ARCH = "i686" ]; then LLVM_TARGET_ARCH=X86 elif [ $TERMUX_ARCH = "x86_64" ]; then LLVM_TARGET_ARCH=X86 + TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" -DCOMPILER_RT_BUILD_SANITIZERS=OFF" else termux_error_exit "Invalid arch: $TERMUX_ARCH" fi TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" -DLLVM_DEFAULT_TARGET_TRIPLE=${LLVM_TRIPLE}" - TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" -DLLVM_TARGET_ARCH=${LLVM_TARGET_ARCH} -DLLVM_TARGETS_TO_BUILD=AArch64;ARM;X86" + TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" -DLLVM_TARGET_ARCH=${LLVM_TARGET_ARCH}" # CPPFLAGS adds the system llvm to the include path, which causes # conflicts with the local patched llvm when compiling ldc @@ -93,64 +107,74 @@ termux_step_pre_configure() { mkdir "$TERMUX_PKG_BUILDDIR" } +# CMake for LLVM has been run: termux_step_post_configure() { + # Cross-compile & install LLVM + cd "$TERMUX_PKG_BUILDDIR" + if test -f build.ninja; then + ninja -j $TERMUX_MAKE_PROCESSES install + fi + + # Replace non-native llvm-config executable with bash script, + # as it is going to be invoked during LDC CMake config. + mv ../llvm-config $LLVM_INSTALL_DIR/bin + + # Invoke CMake for LDC: + TERMUX_PKG_SRCDIR=$OLD_TERMUX_PKG_SRCDIR TERMUX_PKG_BUILDDIR=$OLD_TERMUX_PKG_BUILDDIR cd "$TERMUX_PKG_BUILDDIR" - mv llvm-config llvm/bin - export LDC_FLAGS="-mtriple=$LLVM_TRIPLE" if [ $TERMUX_ARCH = arm ]; then LDC_FLAGS="$LDC_FLAGS;-mcpu=cortex-a8"; fi export LDC_PATH=$TERMUX_PKG_SRCDIR/ldc2-$TERMUX_PKG_VERSION-linux-x86_64 - # Couldn't use -DD_COMPILER_FLAGS_ENV_INIT=\"${LDC_FLAGS//;/ }\"" because of the space - TERMUX_PKG_EXTRA_CONFIGURE_ARGS=" -DD_FLAGS=$LDC_FLAGS \ - -DLLVM_CONFIG=$TERMUX_PKG_BUILDDIR/llvm/bin/llvm-config \ - -DD_COMPILER=$LDC_PATH/bin/ldmd2" + TERMUX_PKG_EXTRA_CONFIGURE_ARGS=" -DLLVM_ROOT_DIR=$LLVM_INSTALL_DIR \ + -DD_COMPILER=$LDC_PATH/bin/ldmd2 \ + -DCMAKE_INSTALL_PREFIX=$TERMUX_PREFIX" termux_step_configure_cmake } termux_step_make() { + # Cross-compile the runtime libraries $LDC_PATH/bin/ldc-build-runtime --ninja -j $TERMUX_MAKE_PROCESSES \ --dFlags="$LDC_FLAGS" --cFlags="$CFLAGS -I$TERMUX_PREFIX/include" \ --targetSystem="Android;Linux;UNIX" --ldcSrcDir="$TERMUX_PKG_SRCDIR" - cd llvm - if test -f build.ninja; then - ninja -j $TERMUX_MAKE_PROCESSES - fi - - cd .. + # Set up ldmd2 for cross-compilation export DFLAGS="${LDC_FLAGS//;/ }" + # Cross-compile LDC executables (linked against runtime libs above) if test -f build.ninja; then ninja -j $TERMUX_MAKE_PROCESSES ldc2 ldmd2 ldc-build-runtime fi - # Build the rdmd scripting wrapper and the dub package manager + # Cross-compile dlang tools and dub: + DMD=$LDC_PATH/bin/ldmd2 - D_FLAGS="-w -de -O" D_LDFLAGS="-fuse-ld=bfd -L$TERMUX_PKG_BUILDDIR/ldc-build-runtime.tmp/lib -lphobos2-ldc -ldruntime-ldc -Wl,--gc-sections -ldl -lm -fPIE -pie -Wl,-z,nocopyreloc ${LDFLAGS}" if [ $TERMUX_ARCH = arm ]; then D_LDFLAGS="$D_LDFLAGS -Wl,--fix-cortex-a8"; fi - $DMD $D_FLAGS -c $TERMUX_PKG_SRCDIR/rdmd/rdmd.d -of=$TERMUX_PKG_BUILDDIR/bin/rdmd.o + cd $TERMUX_PKG_SRCDIR/dlang-tools + $DMD -w -de -c rdmd.d -of=$TERMUX_PKG_BUILDDIR/bin/rdmd.o + $DMD -w -de -c ddemangle.d -of=$TERMUX_PKG_BUILDDIR/bin/ddemangle.o + $DMD -w -de -c DustMite/dustmite.d DustMite/splitter.d -of=$TERMUX_PKG_BUILDDIR/bin/dustmite.o $CC $TERMUX_PKG_BUILDDIR/bin/rdmd.o $D_LDFLAGS -o $TERMUX_PKG_BUILDDIR/bin/rdmd + $CC $TERMUX_PKG_BUILDDIR/bin/ddemangle.o $D_LDFLAGS -o $TERMUX_PKG_BUILDDIR/bin/ddemangle + $CC $TERMUX_PKG_BUILDDIR/bin/dustmite.o $D_LDFLAGS -o $TERMUX_PKG_BUILDDIR/bin/dustmite cd $TERMUX_PKG_SRCDIR/dub - $DMD $D_FLAGS -version=DubUseCurl -Isource -c @build-files.txt -of=$TERMUX_PKG_BUILDDIR/bin/dub.o + $DMD -O -w -version=DubUseCurl -version=DubApplication -Isource -c @build-files.txt -of=$TERMUX_PKG_BUILDDIR/bin/dub.o $CC $TERMUX_PKG_BUILDDIR/bin/dub.o $D_LDFLAGS -o $TERMUX_PKG_BUILDDIR/bin/dub } termux_step_make_install() { - cp bin/{dub,ldc-build-runtime,ldc2,ldmd2,rdmd} $TERMUX_PREFIX/bin - cp $TERMUX_PKG_BUILDDIR/ldc-build-runtime.tmp/lib/lib{druntime,phobos2}*.a $TERMUX_PREFIX/lib - sed -i "/runtime\/druntime\/src/d" bin/ldc2.conf - sed -i "/runtime\/jit-rt\/d/d" bin/ldc2.conf - sed -i "s|$TERMUX_PKG_SRCDIR/runtime/phobos|%%ldcbinarypath%%/../include/d|" bin/ldc2.conf - sed "s|$TERMUX_PKG_BUILDDIR/lib|%%ldcbinarypath%%/../lib|" bin/ldc2.conf > $TERMUX_PREFIX/etc/ldc2.conf + cp bin/{ddemangle,dub,dustmite,ldc-build-runtime,ldc2,ldmd2,rdmd} $TERMUX_PREFIX/bin + cp $TERMUX_PKG_BUILDDIR/ldc-build-runtime.tmp/lib/*.a $TERMUX_PREFIX/lib + sed "s|$TERMUX_PREFIX/|%%ldcbinarypath%%/../|g" bin/ldc2_install.conf > $TERMUX_PREFIX/etc/ldc2.conf + cat $TERMUX_PREFIX/etc/ldc2.conf rm -Rf $TERMUX_PREFIX/include/d mkdir $TERMUX_PREFIX/include/d diff --git a/packages/ldc/ldc-druntime-link-symbols.patch b/packages/ldc/ldc-druntime-link-symbols.patch index a23f32f3d..6c73f141d 100644 --- a/packages/ldc/ldc-druntime-link-symbols.patch +++ b/packages/ldc/ldc-druntime-link-symbols.patch @@ -1,5 +1,5 @@ diff --git a/src/rt/sections_android.d b/src/rt/sections_android.d -index cd8d5535..6a7fcd11 100644 +index 33644151..34a2ae5e 100644 --- a/src/rt/sections_android.d +++ b/runtime/druntime/src/rt/sections_android.d @@ -76,7 +76,11 @@ void initSections() nothrow @nogc @@ -13,9 +13,9 @@ index cd8d5535..6a7fcd11 100644 + else version(AArch64) auto pend = cast(void*)& __bss_end__; + else static assert( false, "Android architecture not supported." ); // _tlsend is a 32-bit int and may not be 64-bit void*-aligned, so align pbeg. - version(D_LP64) pbeg = cast(void*)(cast(size_t)(pbeg + 7) & ~cast(size_t)7); + version (D_LP64) pbeg = cast(void*)(cast(size_t)(pbeg + 7) & ~cast(size_t)7); _sections._gcRanges[0] = pbeg[0 .. pend - pbeg]; -@@ -209,7 +184,11 @@ extern(C) +@@ -180,7 +184,11 @@ extern(C) void* __stop_minfo; } diff --git a/packages/ldc/ldc-druntime-unistd.patch b/packages/ldc/ldc-druntime-unistd.patch new file mode 100644 index 000000000..de437c291 --- /dev/null +++ b/packages/ldc/ldc-druntime-unistd.patch @@ -0,0 +1,170 @@ +diff --git a/src/core/sys/posix/unistd.d b/src/core/sys/posix/unistd.d +index 04de7764..418d63d4 100644 +--- a/src/core/sys/posix/unistd.d ++++ b/runtime/druntime/src/core/sys/posix/unistd.d +@@ -1342,9 +1342,162 @@ else version (CRuntime_Bionic) + enum W_OK = 2; + enum X_OK = 1; + +- enum _SC_PAGESIZE = 0x0027; +- enum _SC_NPROCESSORS_ONLN = 0x0061; +- enum _SC_THREAD_STACK_MIN = 0x004c; ++ enum ++ { ++ _SC_ARG_MAX = 0x0000, ++ _SC_BC_BASE_MAX = 0x0001, ++ _SC_BC_DIM_MAX = 0x0002, ++ _SC_BC_SCALE_MAX = 0x0003, ++ _SC_BC_STRING_MAX = 0x0004, ++ _SC_CHILD_MAX = 0x0005, ++ _SC_CLK_TCK = 0x0006, ++ _SC_COLL_WEIGHTS_MAX = 0x0007, ++ _SC_EXPR_NEST_MAX = 0x0008, ++ _SC_LINE_MAX = 0x0009, ++ _SC_NGROUPS_MAX = 0x000a, ++ _SC_OPEN_MAX = 0x000b, ++ _SC_PASS_MAX = 0x000c, ++ _SC_2_C_BIND = 0x000d, ++ _SC_2_C_DEV = 0x000e, ++ _SC_2_C_VERSION = 0x000f, ++ _SC_2_CHAR_TERM = 0x0010, ++ _SC_2_FORT_DEV = 0x0011, ++ _SC_2_FORT_RUN = 0x0012, ++ _SC_2_LOCALEDEF = 0x0013, ++ _SC_2_SW_DEV = 0x0014, ++ _SC_2_UPE = 0x0015, ++ _SC_2_VERSION = 0x0016, ++ _SC_JOB_CONTROL = 0x0017, ++ _SC_SAVED_IDS = 0x0018, ++ _SC_VERSION = 0x0019, ++ _SC_RE_DUP_MAX = 0x001a, ++ _SC_STREAM_MAX = 0x001b, ++ _SC_TZNAME_MAX = 0x001c, ++ _SC_XOPEN_CRYPT = 0x001d, ++ _SC_XOPEN_ENH_I18N = 0x001e, ++ _SC_XOPEN_SHM = 0x001f, ++ _SC_XOPEN_VERSION = 0x0020, ++ _SC_XOPEN_XCU_VERSION = 0x0021, ++ _SC_XOPEN_REALTIME = 0x0022, ++ _SC_XOPEN_REALTIME_THREADS = 0x0023, ++ _SC_XOPEN_LEGACY = 0x0024, ++ _SC_ATEXIT_MAX = 0x0025, ++ _SC_IOV_MAX = 0x0026, ++ _SC_UIO_MAXIOV = _SC_IOV_MAX, ++ _SC_PAGESIZE = 0x0027, ++ _SC_PAGE_SIZE = 0x0028, ++ _SC_XOPEN_UNIX = 0x0029, ++ _SC_XBS5_ILP32_OFF32 = 0x002a, ++ _SC_XBS5_ILP32_OFFBIG = 0x002b, ++ _SC_XBS5_LP64_OFF64 = 0x002c, ++ _SC_XBS5_LPBIG_OFFBIG = 0x002d, ++ _SC_AIO_LISTIO_MAX = 0x002e, ++ _SC_AIO_MAX = 0x002f, ++ _SC_AIO_PRIO_DELTA_MAX = 0x0030, ++ _SC_DELAYTIMER_MAX = 0x0031, ++ _SC_MQ_OPEN_MAX = 0x0032, ++ _SC_MQ_PRIO_MAX = 0x0033, ++ _SC_RTSIG_MAX = 0x0034, ++ _SC_SEM_NSEMS_MAX = 0x0035, ++ _SC_SEM_VALUE_MAX = 0x0036, ++ _SC_SIGQUEUE_MAX = 0x0037, ++ _SC_TIMER_MAX = 0x0038, ++ _SC_ASYNCHRONOUS_IO = 0x0039, ++ _SC_FSYNC = 0x003a, ++ _SC_MAPPED_FILES = 0x003b, ++ _SC_MEMLOCK = 0x003c, ++ _SC_MEMLOCK_RANGE = 0x003d, ++ _SC_MEMORY_PROTECTION = 0x003e, ++ _SC_MESSAGE_PASSING = 0x003f, ++ _SC_PRIORITIZED_IO = 0x0040, ++ _SC_PRIORITY_SCHEDULING = 0x0041, ++ _SC_REALTIME_SIGNALS = 0x0042, ++ _SC_SEMAPHORES = 0x0043, ++ _SC_SHARED_MEMORY_OBJECTS = 0x0044, ++ _SC_SYNCHRONIZED_IO = 0x0045, ++ _SC_TIMERS = 0x0046, ++ _SC_GETGR_R_SIZE_MAX = 0x0047, ++ _SC_GETPW_R_SIZE_MAX = 0x0048, ++ _SC_LOGIN_NAME_MAX = 0x0049, ++ _SC_THREAD_DESTRUCTOR_ITERATIONS = 0x004a, ++ _SC_THREAD_KEYS_MAX = 0x004b, ++ _SC_THREAD_STACK_MIN = 0x004c, ++ _SC_THREAD_THREADS_MAX = 0x004d, ++ _SC_TTY_NAME_MAX = 0x004e, ++ ++ _SC_THREADS = 0x004f, ++ _SC_THREAD_ATTR_STACKADDR = 0x0050, ++ _SC_THREAD_ATTR_STACKSIZE = 0x0051, ++ _SC_THREAD_PRIORITY_SCHEDULING = 0x0052, ++ _SC_THREAD_PRIO_INHERIT = 0x0053, ++ _SC_THREAD_PRIO_PROTECT = 0x0054, ++ _SC_THREAD_SAFE_FUNCTIONS = 0x0055, ++ ++ _SC_NPROCESSORS_CONF = 0x0060, ++ _SC_NPROCESSORS_ONLN = 0x0061, ++ _SC_PHYS_PAGES = 0x0062, ++ _SC_AVPHYS_PAGES = 0x0063, ++ _SC_MONOTONIC_CLOCK = 0x0064, ++ ++ _SC_2_PBS = 0x0065, ++ _SC_2_PBS_ACCOUNTING = 0x0066, ++ _SC_2_PBS_CHECKPOINT = 0x0067, ++ _SC_2_PBS_LOCATE = 0x0068, ++ _SC_2_PBS_MESSAGE = 0x0069, ++ _SC_2_PBS_TRACK = 0x006a, ++ _SC_ADVISORY_INFO = 0x006b, ++ _SC_BARRIERS = 0x006c, ++ _SC_CLOCK_SELECTION = 0x006d, ++ _SC_CPUTIME = 0x006e, ++ _SC_HOST_NAME_MAX = 0x006f, ++ _SC_IPV6 = 0x0070, ++ _SC_RAW_SOCKETS = 0x0071, ++ _SC_READER_WRITER_LOCKS = 0x0072, ++ _SC_REGEXP = 0x0073, ++ _SC_SHELL = 0x0074, ++ _SC_SPAWN = 0x0075, ++ _SC_SPIN_LOCKS = 0x0076, ++ _SC_SPORADIC_SERVER = 0x0077, ++ _SC_SS_REPL_MAX = 0x0078, ++ _SC_SYMLOOP_MAX = 0x0079, ++ _SC_THREAD_CPUTIME = 0x007a, ++ _SC_THREAD_PROCESS_SHARED = 0x007b, ++ _SC_THREAD_ROBUST_PRIO_INHERIT = 0x007c, ++ _SC_THREAD_ROBUST_PRIO_PROTECT = 0x007d, ++ _SC_THREAD_SPORADIC_SERVER = 0x007e, ++ _SC_TIMEOUTS = 0x007f, ++ _SC_TRACE = 0x0080, ++ _SC_TRACE_EVENT_FILTER = 0x0081, ++ _SC_TRACE_EVENT_NAME_MAX = 0x0082, ++ _SC_TRACE_INHERIT = 0x0083, ++ _SC_TRACE_LOG = 0x0084, ++ _SC_TRACE_NAME_MAX = 0x0085, ++ _SC_TRACE_SYS_MAX = 0x0086, ++ _SC_TRACE_USER_EVENT_MAX = 0x0087, ++ _SC_TYPED_MEMORY_OBJECTS = 0x0088, ++ _SC_V7_ILP32_OFF32 = 0x0089, ++ _SC_V7_ILP32_OFFBIG = 0x008a, ++ _SC_V7_LP64_OFF64 = 0x008b, ++ _SC_V7_LPBIG_OFFBIG = 0x008c, ++ _SC_XOPEN_STREAMS = 0x008d, ++ _SC_XOPEN_UUCP = 0x008e, ++ ++ _SC_LEVEL1_ICACHE_SIZE = 0x008f, ++ _SC_LEVEL1_ICACHE_ASSOC = 0x0090, ++ _SC_LEVEL1_ICACHE_LINESIZE = 0x0091, ++ _SC_LEVEL1_DCACHE_SIZE = 0x0092, ++ _SC_LEVEL1_DCACHE_ASSOC = 0x0093, ++ _SC_LEVEL1_DCACHE_LINESIZE = 0x0094, ++ _SC_LEVEL2_CACHE_SIZE = 0x0095, ++ _SC_LEVEL2_CACHE_ASSOC = 0x0096, ++ _SC_LEVEL2_CACHE_LINESIZE = 0x0097, ++ _SC_LEVEL3_CACHE_SIZE = 0x0098, ++ _SC_LEVEL3_CACHE_ASSOC = 0x0099, ++ _SC_LEVEL3_CACHE_LINESIZE = 0x009a, ++ _SC_LEVEL4_CACHE_SIZE = 0x009b, ++ _SC_LEVEL4_CACHE_ASSOC = 0x009c, ++ _SC_LEVEL4_CACHE_LINESIZE = 0x009d, ++ } + } + else version (Solaris) + { diff --git a/packages/ldc/ldc-x64-sprintf.patch b/packages/ldc/ldc-x64-sprintf.patch index 20eef7c1f..589626d0f 100644 --- a/packages/ldc/ldc-x64-sprintf.patch +++ b/packages/ldc/ldc-x64-sprintf.patch @@ -1,55 +1,54 @@ +diff --git a/dmd/dmangle.d b/dmd/dmangle.d +index 8e2fc5b6f..7de4a02de 100644 +--- a/dmd/dmangle.d ++++ b/dmd/dmangle.d +@@ -926,7 +926,10 @@ public: + + char[36] buffer = void; + // 'A' format yields [-]0xh.hhhhp+-d +- const n = CTFloat.sprint(buffer.ptr, 'A', value); ++ // sprintf/printf with hex formatting is broken for certain long ++ // doubles on Android/x64, so use decimal format instead. ++ char fmt = global.params.isAndroidX86_64 ? 'g' : 'A'; ++ const n = CTFloat.sprint(buffer.ptr, fmt, value); + assert(n < buffer.length); + foreach (const c; buffer[2 .. n]) + { diff --git a/dmd/globals.d b/dmd/globals.d -index 464b8926..1d9befe1 100644 +index 8589b6cf2..5dae07256 100644 --- a/dmd/globals.d +++ b/dmd/globals.d -@@ -123,6 +123,7 @@ struct Param +@@ -139,6 +139,7 @@ struct Param bool is64bit = (size_t.sizeof == 8); // generate 64 bit code; true by default for 64 bit dmd bool isLP64; // generate code for LP64 bool isLinux; // generate code for linux -+ bool isAndroid; // generate code for Android ++ bool isAndroidX86_64; // generate code for Android x86_64 bool isOSX; // generate code for Mac OSX bool isWindows; // generate code for Windows bool isFreeBSD; // generate code for FreeBSD diff --git a/dmd/globals.h b/dmd/globals.h -index 24cd4912..df8a71bd 100644 +index 098116f4d..57429400c 100644 --- a/dmd/globals.h +++ b/dmd/globals.h -@@ -100,6 +100,7 @@ struct Param +@@ -119,6 +119,7 @@ struct Param bool is64bit; // generate 64 bit code bool isLP64; // generate code for LP64 bool isLinux; // generate code for linux -+ bool isAndroid; // generate code for Android ++ bool isAndroidX86_64; // generate code for Android x86_64 bool isOSX; // generate code for Mac OSX bool isWindows; // generate code for Windows bool isFreeBSD; // generate code for FreeBSD diff --git a/driver/main.cpp b/driver/main.cpp -index 26c61e94..f9ec7f7b 100644 +index c8c7ec2c5..18b581759 100644 --- a/driver/main.cpp +++ b/driver/main.cpp -@@ -1023,6 +1023,7 @@ int cppmain(int argc, char **argv) { +@@ -1000,6 +1000,9 @@ int cppmain() { llvm::Triple *triple = new llvm::Triple(gTargetMachine->getTargetTriple()); global.params.targetTriple = triple; global.params.isLinux = triple->isOSLinux(); -+ global.params.isAndroid = triple->getEnvironment() == llvm::Triple::Android; ++ global.params.isAndroidX86_64 = ++ triple->getEnvironment() == llvm::Triple::Android && ++ triple->getArch() == llvm::Triple::x86_64; global.params.isOSX = triple->isOSDarwin(); global.params.isWindows = triple->isOSWindows(); global.params.isFreeBSD = triple->isOSFreeBSD(); -diff --git a/dmd/dmangle.d b/dmd/dmangle.d -index 9fa8593b..ae29e307 100644 ---- a/dmd/dmangle.d -+++ b/dmd/dmangle.d -@@ -911,9 +911,13 @@ public: - buf.writestring(value < CTFloat.zero ? "NINF" : "INF"); - else - { -+ version (IN_LLVM) import gen.llvmhelpers; - enum BUFFER_LEN = 36; - char[BUFFER_LEN] buffer; -- const n = CTFloat.sprint(buffer.ptr, 'A', value); -+ // sprintf/printf with hex formatting is broken for certain long -+ // doubles on Android/x64, so use decimal format instead. -+ char fmt = global.params.isAndroid && isArchx86_64() ? 'g' : 'A'; -+ const n = CTFloat.sprint(buffer.ptr, fmt, value); - assert(n < BUFFER_LEN); - for (int i = 0; i < n; i++) - { diff --git a/packages/ldc/llvm-config.in b/packages/ldc/llvm-config.in index 87225eaed..3803c207c 100644 --- a/packages/ldc/llvm-config.in +++ b/packages/ldc/llvm-config.in @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash show_help () { echo "usage: llvm-config