diff --git a/.circleci/config.yml b/.circleci/config.yml index b9b3f6300a..2b109f471a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -129,7 +129,10 @@ commonSteps: &commonSteps - run: name: Run LIT testsuite when: always - command: cd ../ninja-ldc && ctest -V -R lit-tests + command: | + cd ../ninja-ldc + # Temporarily add LLVM bin dir to PATH, so that e.g. wasm-ld is found. + PATH=$PWD/../llvm-$LLVM_VERSION/bin:$PATH ctest -V -R lit-tests - run: name: Run DMD testsuite when: always diff --git a/driver/linker-gcc.cpp b/driver/linker-gcc.cpp index 421f5d2778..3db8a2ff8d 100644 --- a/driver/linker-gcc.cpp +++ b/driver/linker-gcc.cpp @@ -703,16 +703,28 @@ int linkObjToBinaryGcc(llvm::StringRef outputPath, } #endif - // find gcc for linking - const std::string tool = getGcc(); + // build command-line for gcc-compatible linker driver + // exception: invoke (ld-compatible) linker directly for WebAssembly targets + std::string tool; + std::unique_ptr argsBuilder; +#if LDC_LLVM_VER >= 500 + if (global.params.targetTriple->isOSBinFormatWasm()) { + tool = getProgram("wasm-ld", &opts::linker); + argsBuilder = llvm::make_unique(); + } else { +#endif + tool = getGcc(); + argsBuilder = llvm::make_unique(); +#if LDC_LLVM_VER >= 500 + } +#endif // build arguments - ArgsBuilder argsBuilder; - argsBuilder.build(outputPath, defaultLibNames); + argsBuilder->build(outputPath, defaultLibNames); Logger::println("Linking with: "); Stream logstr = Logger::cout(); - for (const auto &arg : argsBuilder.args) { + for (const auto &arg : argsBuilder->args) { if (!arg.empty()) { logstr << "'" << arg << "' "; } @@ -720,5 +732,5 @@ int linkObjToBinaryGcc(llvm::StringRef outputPath, logstr << "\n"; // FIXME where's flush ? // try to call linker - return executeToolAndWait(tool, argsBuilder.args, global.params.verbose); + return executeToolAndWait(tool, argsBuilder->args, global.params.verbose); } diff --git a/shippable.yml b/shippable.yml index ca866e8ff2..de6d6a432d 100644 --- a/shippable.yml +++ b/shippable.yml @@ -89,7 +89,7 @@ build: # Build and run LDC D unittests - ctest --output-on-failure -R ldc2-unittest # Run LIT testsuite, ignore the errors - - ctest -V -R lit-tests || true + - PATH=$PWD/../llvm/bin:$PATH ctest -V -R lit-tests || true # Run DMD testsuite (non-debug only for now), ignore the errors - DMD_TESTSUITE_MAKE_ARGS='-j16 -k' ctest -V -R dmd-testsuite -E "-debug$" || true # Run druntime/Phobos unittests (non-debug only for now, excl. hanging core.thread), ignore the errors diff --git a/tests/baremetal/wasm.d b/tests/baremetal/wasm.d index 3b86404763..a387d0bf97 100644 --- a/tests/baremetal/wasm.d +++ b/tests/baremetal/wasm.d @@ -1,7 +1,7 @@ // Compile and link directly to WebAssembly. // REQUIRES: target_WebAssembly -// RUN: %ldc -mtriple=wasm32-unknown-unknown-wasm -link-internally %s %baremetal_args +// RUN: %ldc -mtriple=wasm32-unknown-unknown-wasm %s %baremetal_args extern(C): // no mangling, no arguments order reversal