diff --git a/bsc/llvm-ompss2/clang.nix b/bsc/llvm-ompss2/clang.nix index a552712..7573204 100644 --- a/bsc/llvm-ompss2/clang.nix +++ b/bsc/llvm-ompss2/clang.nix @@ -67,7 +67,7 @@ stdenv.mkDerivation rec { "-DCMAKE_CXX_FLAGS_DEBUG=-g -ggnu-pubnames" "-DCMAKE_EXE_LINKER_FLAGS_DEBUG=-Wl,-gdb-index" "-DLLVM_LIT_ARGS=-sv --xunit-xml-output=xunit.xml" - "-DLLVM_ENABLE_PROJECTS=clang;openmp;compiler-rt;flang" + "-DLLVM_ENABLE_PROJECTS=clang;openmp;compiler-rt;flang;lld" "-DLLVM_ENABLE_ASSERTIONS=${enableAssertions}" "-DLLVM_INSTALL_TOOLCHAIN_ONLY=ON" "-DCMAKE_INSTALL_BINDIR=bin" diff --git a/bsc/llvm-ompss2/default.nix b/bsc/llvm-ompss2/default.nix index 4627656..f57c450 100644 --- a/bsc/llvm-ompss2/default.nix +++ b/bsc/llvm-ompss2/default.nix @@ -4,14 +4,27 @@ , nanos6 , clangOmpss2Unwrapped , wrapCCWith +, llvmPackages }: let + + # We need to replace the lld linker from bintools with our linker just built, + # otherwise we run into incompatibility issues when mixing compiler and linker + # versions. + bintools-unwrapped = llvmPackages.tools.bintools-unwrapped.override { + lld = clangOmpss2Unwrapped; + }; + bintools = llvmPackages.tools.bintools.override { + bintools = bintools-unwrapped; + }; + targetConfig = stdenv.targetPlatform.config; inherit gcc nanos6; -in wrapCCWith rec { cc = clangOmpss2Unwrapped; +in wrapCCWith { + inherit cc bintools; extraBuildCommands = '' echo "-target ${targetConfig}" >> $out/nix-support/cc-cflags echo "-B${gcc.cc}/lib/gcc/${targetConfig}/${gcc.version}" >> $out/nix-support/cc-cflags diff --git a/overlay.nix b/overlay.nix index 8f701a4..ccbf4d5 100644 --- a/overlay.nix +++ b/overlay.nix @@ -105,6 +105,7 @@ let clangOmpss2 = appendPasstru ( callPackage ./bsc/llvm-ompss2/default.nix { + llvmPackages = self.llvmPackages_latest; clangOmpss2Unwrapped = bsc.clangOmpss2Unwrapped; }) { CC = "clang"; CXX = "clang++"; }; @@ -113,6 +114,11 @@ let clangOmpss2Unwrapped = bsc.clangOmpss2UnwrappedGit; }) { CC = "clang"; CXX = "clang++"; }; + stdenvClangOmpss2 = self.stdenv.override { + cc = bsc.clangOmpss2; + allowedRequisites = null; + }; + mcxx = bsc.mcxxRelease; mcxxRelease = callPackage ./bsc/mcxx/default.nix { }; mcxxGit = callPackage ./bsc/mcxx/git.nix { }; @@ -302,6 +308,7 @@ let compilers.hello-c = callPackage ./test/compilers/hello-c.nix { }; compilers.hello-cpp = callPackage ./test/compilers/hello-cpp.nix { }; compilers.hello-f = callPackage ./test/compilers/hello-f.nix { }; + compilers.lto = callPackage ./test/compilers/lto.nix { }; compilers.intel2023.icx.c = compilers.hello-c.override { stdenv = bsc.intel2023.stdenv; }; @@ -317,6 +324,9 @@ let compilers.intel2023.ifort = compilers.hello-f.override { stdenv = bsc.intel2023.stdenv-ifort; }; + compilers.clangOmpss2.lto = compilers.lto.override { + stdenv = bsc.stdenvClangOmpss2; + }; }; testAll = with bsc.test; [ @@ -325,6 +335,7 @@ let compilers.intel2023.icx.cpp compilers.intel2023.icc.cpp compilers.intel2023.ifort + compilers.clangOmpss2.lto ]; ci = import ./test/ci.nix { diff --git a/test/compilers/lto.nix b/test/compilers/lto.nix new file mode 100644 index 0000000..337bf51 --- /dev/null +++ b/test/compilers/lto.nix @@ -0,0 +1,43 @@ +{ stdenv, writeText, which, strace }: + +let + hello_c = writeText "hello.c" '' + #include + #include + #include + + int main() + { + printf("Hello world!\n"); + return 0; + } + ''; +in + +stdenv.mkDerivation rec { + version = "0.0.1"; + name = "lto-c"; + buildInputs = [ stdenv which strace ]; + src = hello_c; + dontUnpack = true; + dontConfigure = true; + NIX_DEBUG = 0; + buildPhase = '' + set -x + echo CC=$CC + echo LD=$LD + echo ------------------------------------------- + env + echo ------------------------------------------- + + cp ${hello_c} hello.c + $CC -v -flto hello.c -o hello + ./hello + + set +x + ''; + + installPhase = '' + touch $out + ''; +}