Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/dmd2/root/port.c b/dmd2/root/port.c
- index a2a32cd..02412e7 100644
- --- a/dmd2/root/port.c
- +++ b/dmd2/root/port.c
- @@ -654,10 +654,6 @@ longdouble Port::strtold(const char *p, char **endp)
- #if __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __NetBSD__ || __DragonFly__ || __HAIKU__
- #include <math.h>
- -#if __linux__
- -#include <bits/nan.h>
- -#include <bits/mathdef.h>
- -#endif
- #if __FreeBSD__ && __i386__
- #include <ieeefp.h>
- #endif
- diff --git a/driver/codegenerator.cpp b/driver/codegenerator.cpp
- index 2e8c768..92e4c11 100644
- --- a/driver/codegenerator.cpp
- +++ b/driver/codegenerator.cpp
- @@ -81,6 +81,18 @@ void emitSymbolAddrGlobal(llvm::Module &lm, const char *symbolName,
- lm, voidPtr, false, llvm::GlobalValue::ExternalLinkage,
- llvm::ConstantExpr::getBitCast(targetSymbol, voidPtr), addrName);
- }
- +void emitSymbolAddrGlobal2(llvm::Module &lm, const char *symbolName,
- + const char *dataSection, const char *addrName) {
- + llvm::Type *voidPtr =
- + llvm::PointerType::get(llvm::Type::getInt8Ty(lm.getContext()), 0);
- + auto targetSymbol = new llvm::GlobalVariable(
- + lm, voidPtr, false, llvm::GlobalValue::ExternalWeakLinkage, 0,
- + addrName);
- + auto Symbol = new llvm::GlobalVariable(
- + lm, voidPtr, false, llvm::GlobalValue::ExternalLinkage,
- + llvm::ConstantExpr::getBitCast(targetSymbol, voidPtr), symbolName);
- + Symbol->setSection(dataSection);
- +}
- }
- namespace ldc {
- @@ -216,6 +228,8 @@ void CodeGenerator::emit(Module *m) {
- emitSymbolAddrGlobal(ir_->module, "__bss_start", "_d_execBssBegAddr");
- emitSymbolAddrGlobal(ir_->module, "_end", "_d_execBssEndAddr");
- }
- + emitSymbolAddrGlobal2(ir_->module, "_tlsstart", ".tdata", "_tlsBegAddr");
- + emitSymbolAddrGlobal2(ir_->module, "_tlsend", ".tcommon", "_tlsEndAddr");
- }
- finishLLModule(m);
- diff --git a/driver/linker.cpp b/driver/linker.cpp
- index 3cc1e4a..043df35 100644
- --- a/driver/linker.cpp
- +++ b/driver/linker.cpp
- @@ -165,7 +165,7 @@ static int linkObjToBinaryGcc(bool sharedLib, bool fullyStatic) {
- switch (global.params.targetTriple.getOS()) {
- case llvm::Triple::Linux:
- addSoname = true;
- - args.push_back("-lrt");
- + //args.push_back("-lrt");
- if (!opts::disableLinkerStripDead) {
- args.push_back("-Wl,--gc-sections");
- }
- @@ -176,7 +176,7 @@ static int linkObjToBinaryGcc(bool sharedLib, bool fullyStatic) {
- case llvm::Triple::OpenBSD:
- case llvm::Triple::DragonFly:
- addSoname = true;
- - args.push_back("-lpthread");
- + //args.push_back("-lpthread");
- args.push_back("-lm");
- break;
- diff --git a/driver/main.cpp b/driver/main.cpp
- index bc6e6c1..1f8b58e 100644
- --- a/driver/main.cpp
- +++ b/driver/main.cpp
- @@ -737,6 +737,8 @@ static void registerPredefinedTargetVersions() {
- case llvm::Triple::Linux:
- if (global.params.targetTriple.getEnvironment() == llvm::Triple::Android) {
- VersionCondition::addPredefinedGlobalIdent("Android");
- + VersionCondition::addPredefinedGlobalIdent("linux");
- + VersionCondition::addPredefinedGlobalIdent("Posix");
- VersionCondition::addPredefinedGlobalIdent("CRuntime_Bionic");
- } else {
- VersionCondition::addPredefinedGlobalIdent("linux");
- diff --git a/driver/targetmachine.cpp b/driver/targetmachine.cpp
- index e64efd7..47fadbc 100644
- --- a/driver/targetmachine.cpp
- +++ b/driver/targetmachine.cpp
- @@ -506,6 +506,10 @@ llvm::TargetMachine *createTargetMachine(
- relocModel = llvm::Reloc::PIC_;
- }
- + if (triple.getEnvironment() == llvm::Triple::Android) {
- + relocModel = llvm::Reloc::PIC_;
- + }
- +
- if (floatABI == FloatABI::Default) {
- switch (triple.getArch()) {
- default: // X86, ...
- diff --git a/gen/abi.cpp b/gen/abi.cpp
- index fa24b0a..d42d815 100644
- --- a/gen/abi.cpp
- +++ b/gen/abi.cpp
- @@ -201,7 +201,7 @@ struct UnknownTargetABI : TargetABI {
- return (rt->ty == Tstruct || rt->ty == Tsarray);
- }
- - bool passByVal(Type *t) override { return t->toBasetype()->ty == Tstruct; }
- + bool passByVal(Type *t) override { return false; }//t->toBasetype()->ty == Tstruct; }
- void rewriteFunctionType(TypeFunction *t, IrFuncTy &fty) override {
- // why?
- diff --git a/gen/module.cpp b/gen/module.cpp
- index 76c2b0a..04d1706 100644
- --- a/gen/module.cpp
- +++ b/gen/module.cpp
- @@ -935,7 +935,7 @@ static void genModuleInfo(Module *m, bool emitFullModuleInfo) {
- b.finalize(moduleInfoSym->getType()->getPointerElementType(), moduleInfoSym);
- moduleInfoSym->setLinkage(llvm::GlobalValue::ExternalLinkage);
- - if (global.params.targetTriple.isOSLinux() || global.params.targetTriple.isOSFreeBSD() ||
- + if ((global.params.targetTriple.isOSLinux() && global.params.targetTriple.getEnvironment() != llvm::Triple::Android)|| global.params.targetTriple.isOSFreeBSD() ||
- #if LDC_LLVM_VER > 305
- global.params.targetTriple.isOSNetBSD() || global.params.targetTriple.isOSOpenBSD() ||
- global.params.targetTriple.isOSDragonFly()
- diff --git a/gen/runtime.cpp b/gen/runtime.cpp
- index 5a32dc3..68497b0 100644
- --- a/gen/runtime.cpp
- +++ b/gen/runtime.cpp
- @@ -652,7 +652,7 @@ static void buildRuntimeModule() {
- {objectTy});
- // void _d_dso_registry(CompilerDSOData* data)
- - if (global.params.targetTriple.isOSLinux() || global.params.targetTriple.isOSFreeBSD() ||
- + if ((global.params.targetTriple.isOSLinux() && global.params.targetTriple.getEnvironment() != llvm::Triple::Android) || global.params.targetTriple.isOSFreeBSD() ||
- #if LDC_LLVM_VER > 305
- global.params.targetTriple.isOSNetBSD() || global.params.targetTriple.isOSOpenBSD() ||
- global.params.targetTriple.isOSDragonFly()
- diff --git a/runtime/CMakeLists.txt b/runtime/CMakeLists.txt
- index be5d71e..6d3f5e2 100644
- --- a/runtime/CMakeLists.txt
- +++ b/runtime/CMakeLists.txt
- @@ -272,10 +272,23 @@ macro(dc input_d d_flags output_dir output_suffix outlist_o outlist_bc)
- set(dc_flags --output-o)
- endif()
- + set(cur_d_flags ${d_flags})
- + if("${cur_d_flags}" MATCHES "-release")
- + if("${input_d}" MATCHES "std/exception.d")
- + list(APPEND cur_d_flags -disable-inlining)
- + elseif("${input_d}" MATCHES "std/internal/math/errorfunction.d")
- + list(APPEND cur_d_flags -disable-inlining)
- + elseif("${input_d}" MATCHES "std/math.d")
- + list(APPEND cur_d_flags -disable-inlining)
- + elseif("${input_d}" MATCHES "std/random.d")
- + string(REPLACE "-O3" "-O0" cur_d_flags "${cur_d_flags}")
- + endif()
- + endif()
- +
- add_custom_command(
- OUTPUT
- ${outfiles}
- - COMMAND ${LDC_EXE} ${dc_flags} -c -I${RUNTIME_DIR}/src -I${RUNTIME_DIR}/src/gc ${input_d} -of${output_o} ${d_flags}
- + COMMAND ${LDC_EXE} ${dc_flags} -c -I${RUNTIME_DIR}/src -I${RUNTIME_DIR}/src/gc ${input_d} -of${output_o} ${cur_d_flags}
- WORKING_DIRECTORY ${PROJECT_PARENT_DIR}
- DEPENDS ${input_d}
- ${LDC_EXE}
- @@ -473,7 +486,9 @@ endmacro()
- # Set up build targets.
- #
- -set(RT_CFLAGS "")
- +set(RT_CFLAGS "-fpic -ffunction-sections -funwind-tables -fstack-protector-strong -Wno-invalid-command-line-argument -Wno-unused-command-line-argument -no-canonical-prefixes -fno-integrated-as -target armv7-none-linux-androideabi -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -Os -g -DNDEBUG -fomit-frame-pointer -fno-strict-aliasing -DANDROID -Wa,--noexecstack -Wformat -Werror=format-security")
- +set(RT_LDFLAGS "-Wl,-z,nocopyreloc;-lgcc;-target;armv7-none-linux-androideabi;-no-canonical-prefixes;-Wl,--fix-cortex-a8;-Wl,--no-undefined;-Wl,-z,noexecstack;-Wl,-z,relro;-Wl,-z,now;-mthumb;-Wl,--export-dynamic;-lc;-lm")
- +set(TEST_SO_LDFLAGS "-Wl,-soname,libnative-activity${name_suffix}.so;-shared;-lgcc;-no-canonical-prefixes;-target;armv7-none-linux-androideabi;-Wl,--fix-cortex-a8;-Wl,--no-undefined;-Wl,-z,noexecstack;-Wl,-z,relro;-Wl,-z,now;-mthumb;-llog;-landroid;-lEGL;-lGLESv1_CM;-lc;-lm")
- # This is a bit of a mess as we need to join the two libraries together on
- # OS X before installing them. After this has run, LIBS_TO_INSTALL contains
- @@ -652,6 +667,12 @@ macro(build_test_runner name_suffix d_flags c_flags)
- if(PHOBOS2_DIR)
- set(phobos2_o "")
- set(phobos2_bc "")
- + set(test_runner_o "")
- + set(test_runner ${PROJECT_BINARY_DIR}/test-runner${name_suffix}${CMAKE_EXECUTABLE_SUFFIX})
- + set(ANDROID_DIR "${PROJECT_PARENT_DIR}/../android")
- + set(android_native_app_glue_o "${ANDROID_DIR}/samples/native-activity/android_native_app_glue.o")
- + set(test_runner_so ${ANDROID_DIR}/samples/native-activity/libs/armeabi-v7a/libnative-activity${name_suffix}.so)
- +
- compile_phobos2("${flags}" "-unittest${name_suffix}" "" phobos2_o phobos2_bc)
- set(phobos2-casm phobos2-ldc-casm${name_suffix})
- @@ -666,6 +687,68 @@ macro(build_test_runner name_suffix d_flags c_flags)
- set_target_properties(${phobos2-casm} PROPERTIES EXCLUDE_FROM_ALL ON EXCLUDE_FROM_DEFAULT_BUILD ON)
- add_custom_target(phobos2-ldc-unittest${name_suffix} DEPENDS ${phobos2_o} ${phobos2-casm})
- + set(runner_flags "${flags}")
- + if("${flags}" MATCHES "-debug")
- + list(APPEND runner_flags -d-debug)
- + endif()
- + dc("${RUNTIME_DIR}/src/test_runner.d" "${runner_flags}" "${RUNTIME_DIR}"
- + "${name_suffix}" test_runner_o druntime_bc)
- + add_custom_command(
- + OUTPUT ${test_runner}
- + COMMAND ${CMAKE_C_COMPILER} ${RT_LDFLAGS} ${test_runner_o}
- + ${druntime_o} ${phobos2_o}
- + "${output_path}/lib${druntime-casm}.a"
- + "${output_path}/lib${phobos2-casm}.a"
- + -o${test_runner}
- + WORKING_DIRECTORY ${PROJECT_PARENT_DIR}
- + DEPENDS ${CMAKE_C_COMPILER}
- + ${test_runner_o}
- + ${druntime_o}
- + ${druntime-casm}
- + ${phobos2_o}
- + ${phobos2-casm}
- + )
- + add_custom_target(test-runner${name_suffix} DEPENDS ${test_runner})
- + set(test_runner_apk_o "")
- + dc("${RUNTIME_DIR}/src/test_runner.d" "${runner_flags};-d-version=apk;-I${ANDROID_DIR}" "${RUNTIME_DIR}"
- + "-apk${name_suffix}" test_runner_apk_o druntime_bc)
- + set(file_apk_o "")
- + dc("${PHOBOS2_DIR}/std/file.d" "${flags};-d-version=apk" "${PHOBOS2_DIR}"
- + "-apk-unittest${name_suffix}" file_apk_o phobos2_bc)
- + set(main_o "")
- + dc("${ANDROID_DIR}/samples/native-activity/jni/main.d" "${D_FLAGS};${d_flags};-I${ANDROID_DIR}" "${RUNTIME_DIR}"
- + "${name_suffix}" main_o druntime_bc)
- + set(sensor_o "")
- + dc("${ANDROID_DIR}/android/sensor.d" "${D_FLAGS};${d_flags};-I${ANDROID_DIR}" "${RUNTIME_DIR}"
- + "${name_suffix}" sensor_o druntime_bc)
- + string(REPLACE " " ";" RT_CFLAGS${name_suffix} ${RT_CFLAGS})
- + add_custom_command(
- + OUTPUT ${android_native_app_glue_o}
- + COMMAND ${CMAKE_C_COMPILER} ${RT_CFLAGS} -c "${ANDROID_DIR}/samples/native-activity/android_native_app_glue.c" -o ${android_native_app_glue_o}
- + WORKING_DIRECTORY ${PROJECT_PARENT_DIR}
- + DEPENDS ${CMAKE_C_COMPILER}
- + )
- + list(REMOVE_ITEM phobos2_o "${PROJECT_PARENT_DIR}/build/runtime/std/file-unittest${name_suffix}.o")
- + add_custom_command(
- + OUTPUT ${test_runner_so}
- + COMMAND ${CMAKE_C_COMPILER} ${TEST_SO_LDFLAGS}
- + ${main_o} ${sensor_o} ${test_runner_apk_o}
- + ${file_apk_o} ${android_native_app_glue_o}
- + ${druntime_o} ${phobos2_o}
- + "${output_path}/lib${druntime-casm}.a"
- + "${output_path}/lib${phobos2-casm}.a"
- + -o${test_runner_so}
- + WORKING_DIRECTORY ${PROJECT_PARENT_DIR}
- + DEPENDS ${CMAKE_C_COMPILER}
- + ${main_o} ${sensor_o}
- + ${test_runner_apk_o} ${android_native_app_glue_o}
- + ${druntime_o}
- + ${druntime-casm}
- + ${phobos2_o}
- + ${phobos2-casm}
- + ${file_apk_o}
- + )
- + add_custom_target(test-runner-apk${name_suffix} DEPENDS ${test_runner_so})
- add_test(build-phobos2-ldc-unittest${name_suffix} "${CMAKE_COMMAND}"
- --build ${CMAKE_BINARY_DIR} --target phobos2-ldc-unittest${name_suffix})
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement