From 1db40a1f1cdacbefd81a468324444e3347905409 Mon Sep 17 00:00:00 2001 From: Jacek Generowicz Date: Wed, 16 Aug 2023 22:32:47 +0200 Subject: [PATCH 01/16] Replace clang with gcc in devShell --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index fb26f92f..79df3274 100644 --- a/flake.nix +++ b/flake.nix @@ -24,7 +24,7 @@ in { - devShell = pkgs.mkShell.override { stdenv = pkgs.clang_16.stdenv; } { + devShell = pkgs.mkShell { name = "G4-examples-devenv"; packages = with pkgs; [ From cbd5c4d66b8a63f3b79b4e20f6c82e5d77811d25 Mon Sep 17 00:00:00 2001 From: Jacek Generowicz Date: Thu, 10 Aug 2023 12:21:07 +0200 Subject: [PATCH 02/16] Disallow MacOS failures on GHA --- .github/workflows/test.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8818feb5..e57057e8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -16,13 +16,9 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-22.04] + os: [ubuntu-22.04, macos-12] py: [311] allow-fail: [false] - include: - - os: macos-12 - py: 311 - allow-fail: true steps: - uses: actions/checkout@v3.5.3 From ff2b46f7e254a5723b5d20314fffee7554deb6da Mon Sep 17 00:00:00 2001 From: Jacek Generowicz Date: Thu, 10 Aug 2023 11:49:04 +0200 Subject: [PATCH 03/16] Add target_link_options(Nain4 PRIVATE -undefined dynamic_lookup) --- nain4/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nain4/CMakeLists.txt b/nain4/CMakeLists.txt index a3fa5861..3c34bb1a 100644 --- a/nain4/CMakeLists.txt +++ b/nain4/CMakeLists.txt @@ -45,6 +45,8 @@ FILE(GLOB HEADERS ${PROJECT_SOURCE_DIR}/*.hh) add_library(Nain4 SHARED ${SOURCES} ${HEADERS}) +target_link_options(Nain4 PRIVATE -undefined dynamic_lookup) + #set_target_properties(Nain4 PROPERTIES ENABLE_EXPORTS ON) #---------------------------------------------------------------------------- From fa329a614c2653b75ff24cef9bda560169ad81c4 Mon Sep 17 00:00:00 2001 From: Jacek Generowicz Date: Thu, 10 Aug 2023 12:10:34 +0200 Subject: [PATCH 04/16] Add target_link_options(nain4-tests PRIVATE -undefined dynamic_lookup) --- nain4/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/nain4/CMakeLists.txt b/nain4/CMakeLists.txt index 3c34bb1a..eb5fa4a9 100644 --- a/nain4/CMakeLists.txt +++ b/nain4/CMakeLists.txt @@ -81,6 +81,7 @@ set(ALL_TEST_SOURCES # TODO including headers in add_executable apparently makes them show up in IDEs. Verify how? add_executable(nain4-tests ${ALL_TEST_SOURCES}) +target_link_options(nain4-tests PRIVATE -undefined dynamic_lookup) target_link_libraries( From f5485edfb762fa68bf3eb6e21f3027b2831cc726 Mon Sep 17 00:00:00 2001 From: Jacek Generowicz Date: Thu, 10 Aug 2023 12:13:18 +0200 Subject: [PATCH 05/16] Use -undefined dynamic_lookup only on APPLE --- nain4/CMakeLists.txt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/nain4/CMakeLists.txt b/nain4/CMakeLists.txt index eb5fa4a9..e594b951 100644 --- a/nain4/CMakeLists.txt +++ b/nain4/CMakeLists.txt @@ -45,7 +45,9 @@ FILE(GLOB HEADERS ${PROJECT_SOURCE_DIR}/*.hh) add_library(Nain4 SHARED ${SOURCES} ${HEADERS}) -target_link_options(Nain4 PRIVATE -undefined dynamic_lookup) +if(APPLE) + target_link_options(Nain4 PRIVATE -undefined dynamic_lookup) +endif() #set_target_properties(Nain4 PROPERTIES ENABLE_EXPORTS ON) @@ -81,7 +83,10 @@ set(ALL_TEST_SOURCES # TODO including headers in add_executable apparently makes them show up in IDEs. Verify how? add_executable(nain4-tests ${ALL_TEST_SOURCES}) -target_link_options(nain4-tests PRIVATE -undefined dynamic_lookup) + +if(APPLE) + target_link_options(nain4-tests PRIVATE -undefined dynamic_lookup) +endif() target_link_libraries( From 91ba4756ddae5236c55b437946c64cbfa852a973 Mon Sep 17 00:00:00 2001 From: Jacek Generowicz Date: Wed, 16 Aug 2023 22:54:44 +0200 Subject: [PATCH 06/16] Remove clang{16,_tools} from devShell.packages --- flake.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index 79df3274..fc1105d4 100644 --- a/flake.nix +++ b/flake.nix @@ -36,8 +36,8 @@ geant4.data.G4SAIDDATA geant4.data.G4PARTICLEXS geant4.data.G4NDL - clang_16 - clang-tools + # clang_16 + # clang-tools cmake cmake-language-server catch2_3 From b24bd8820b8d57bba5e81eebf372c0394d109894 Mon Sep 17 00:00:00 2001 From: Jacek Generowicz Date: Wed, 16 Aug 2023 22:50:54 +0200 Subject: [PATCH 07/16] REVERTME: disable compile-time tests on GHA --- .github/workflows/test.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e57057e8..2e7a8797 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -47,9 +47,6 @@ jobs: - name: Run client-side tests run: nix develop -c just test-client-side - - name: Run compile-time tests - run: nix develop -c just test-compile-time - - name: Run nain4 examples run: nix develop -c just test-examples From c6215ae174dbc7edd06f22492d206ce1233b02ff Mon Sep 17 00:00:00 2001 From: Jacek Generowicz Date: Thu, 17 Aug 2023 09:45:19 +0200 Subject: [PATCH 08/16] Factor packages definition out of mkShell --- flake.nix | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/flake.nix b/flake.nix index fc1105d4..ca4fac43 100644 --- a/flake.nix +++ b/flake.nix @@ -22,29 +22,34 @@ enableRaytracerX11 = false; }); + my-packages = with pkgs; [ + my-geant4 + geant4.data.G4PhotonEvaporation + geant4.data.G4EMLOW + geant4.data.G4RadioactiveDecay + geant4.data.G4ENSDFSTATE + geant4.data.G4SAIDDATA + geant4.data.G4PARTICLEXS + geant4.data.G4NDL + cmake + cmake-language-server + catch2_3 + just + gnused # For hacking CMAKE_EXPORT stuff into CMakeLists.txt + mdbook + ] ++ lib.optionals stdenv.isDarwin [ + + ] ++ lib.optionals stdenv.isLinux [ + clang_16 + clang-tools + ]; + in { devShell = pkgs.mkShell { name = "G4-examples-devenv"; - packages = with pkgs; [ - my-geant4 - geant4.data.G4PhotonEvaporation - geant4.data.G4EMLOW - geant4.data.G4RadioactiveDecay - geant4.data.G4ENSDFSTATE - geant4.data.G4SAIDDATA - geant4.data.G4PARTICLEXS - geant4.data.G4NDL - # clang_16 - # clang-tools - cmake - cmake-language-server - catch2_3 - just - gnused # For hacking CMAKE_EXPORT stuff into CMakeLists.txt - mdbook - ]; + packages = my-packages; G4_DIR = "${pkgs.geant4}"; G4_EXAMPLES_DIR = "${pkgs.geant4}/share/Geant4-11.0.4/examples/"; From 5b6e5a9df789f9ceb9434326116c7c5887023bcd Mon Sep 17 00:00:00 2001 From: Jacek Generowicz Date: Thu, 17 Aug 2023 09:45:57 +0200 Subject: [PATCH 09/16] Clang on Linux, stdenv on Darwin --- flake.nix | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index ca4fac43..742522da 100644 --- a/flake.nix +++ b/flake.nix @@ -12,6 +12,7 @@ flake-utils.lib.eachSystem ["x86_64-linux" "i686-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin"] (system: let pkgs = import nixpkgs { inherit system; }; + my-geant4 = (pkgs.geant4.override { enableMultiThreading = false; enableInventor = false; @@ -44,9 +45,14 @@ clang-tools ]; + my-mkShell = pkgs.mkShell.override { + stdenv = if pkgs.stdenv.isDarwin then pkgs. stdenv + else pkgs.llvmPackages_16.stdenv; + }; + in { - devShell = pkgs.mkShell { + devShell = my-mkShell { name = "G4-examples-devenv"; packages = my-packages; From cf356bac24dc6d568544433673fe3ac20e681e38 Mon Sep 17 00:00:00 2001 From: Jacek Generowicz Date: Thu, 17 Aug 2023 11:28:15 +0200 Subject: [PATCH 10/16] Revert previous commit before alternative solution --- flake.nix | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/flake.nix b/flake.nix index 742522da..ca4fac43 100644 --- a/flake.nix +++ b/flake.nix @@ -12,7 +12,6 @@ flake-utils.lib.eachSystem ["x86_64-linux" "i686-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin"] (system: let pkgs = import nixpkgs { inherit system; }; - my-geant4 = (pkgs.geant4.override { enableMultiThreading = false; enableInventor = false; @@ -45,14 +44,9 @@ clang-tools ]; - my-mkShell = pkgs.mkShell.override { - stdenv = if pkgs.stdenv.isDarwin then pkgs. stdenv - else pkgs.llvmPackages_16.stdenv; - }; - in { - devShell = my-mkShell { + devShell = pkgs.mkShell { name = "G4-examples-devenv"; packages = my-packages; From 57c718b8fa9320cc57c69f29f0bbb5661d15a220 Mon Sep 17 00:00:00 2001 From: Jacek Generowicz Date: Thu, 17 Aug 2023 09:53:24 +0200 Subject: [PATCH 11/16] Use libc++ 11 with clang 16 on Darwin --- flake.nix | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/flake.nix b/flake.nix index ca4fac43..0b55ad60 100644 --- a/flake.nix +++ b/flake.nix @@ -22,6 +22,23 @@ enableRaytracerX11 = false; }); + # Should be able to remove this, once https://github.com/NixOS/nixpkgs/issues/234710 is merged + clang_16 = if pkgs.stdenv.isDarwin + then pkgs.llvmPackages_16.clang.override rec { + libc = pkgs.darwin.Libsystem; + bintools = pkgs.bintools.override { inherit libc; }; + inherit (pkgs.llvmPackages) libcxx; + extraPackages = [ + pkgs.llvmPackages.libcxxabi + # Use the compiler-rt associated with clang, but use the libc++abi from the stdenv + # to avoid linking against two different versions (for the same reasons as above). + (pkgs.llvmPackages_16.compiler-rt.override { + inherit (pkgs.llvmPackages) libcxxabi; + }) + ]; + } + else pkgs.llvmPackages.clang; + my-packages = with pkgs; [ my-geant4 geant4.data.G4PhotonEvaporation @@ -31,6 +48,8 @@ geant4.data.G4SAIDDATA geant4.data.G4PARTICLEXS geant4.data.G4NDL + clang_16 + clang-tools cmake cmake-language-server catch2_3 @@ -40,13 +59,11 @@ ] ++ lib.optionals stdenv.isDarwin [ ] ++ lib.optionals stdenv.isLinux [ - clang_16 - clang-tools ]; in { - devShell = pkgs.mkShell { + devShell = pkgs.mkShell.override { stdenv = pkgs.clang_16.stdenv; } { name = "G4-examples-devenv"; packages = my-packages; From c148aee804505bc992c4d6fb72aee1c56df6739b Mon Sep 17 00:00:00 2001 From: Jacek Generowicz Date: Thu, 17 Aug 2023 10:10:13 +0200 Subject: [PATCH 12/16] Re-enable compile-time tests on GHA --- .github/workflows/test.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2e7a8797..e57057e8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -47,6 +47,9 @@ jobs: - name: Run client-side tests run: nix develop -c just test-client-side + - name: Run compile-time tests + run: nix develop -c just test-compile-time + - name: Run nain4 examples run: nix develop -c just test-examples From 2fb8b4fbc020e3366797484f76f4f0b54fd93a82 Mon Sep 17 00:00:00 2001 From: Jacek Generowicz Date: Thu, 17 Aug 2023 14:34:53 +0200 Subject: [PATCH 13/16] Change GIT_TAG: v0.1.8 -> origin/fix-darwin --- client_side_tests/client_fetch_content/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client_side_tests/client_fetch_content/CMakeLists.txt b/client_side_tests/client_fetch_content/CMakeLists.txt index 72d1e44c..1d47b215 100644 --- a/client_side_tests/client_fetch_content/CMakeLists.txt +++ b/client_side_tests/client_fetch_content/CMakeLists.txt @@ -10,7 +10,7 @@ set(FETCHCONTENT_UPDATES_DISCONNECTED ON CACHE BOOL "Cache package contents to a FetchContent_Declare( Nain4 GIT_REPOSITORY https://github.com/jacg/nain4.git - GIT_TAG v0.1.8 + GIT_TAG origin/fix-darwin # make sure that no other nain4 installation is used OVERRIDE_FIND_PACKAGE SOURCE_SUBDIR nain4 From a5f796fb432201dbe010822d92e83a8ccd8e9055 Mon Sep 17 00:00:00 2001 From: Gonzalo Martinez Lema Date: Thu, 17 Aug 2023 17:47:51 +0300 Subject: [PATCH 14/16] Make sure failing commands don't go unnoticed --- client_side_tests/test_fetch_content_recompile.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/client_side_tests/test_fetch_content_recompile.sh b/client_side_tests/test_fetch_content_recompile.sh index f6f13c71..c36785d1 100755 --- a/client_side_tests/test_fetch_content_recompile.sh +++ b/client_side_tests/test_fetch_content_recompile.sh @@ -1,4 +1,5 @@ #!/bin/bash +set -e tmp_dir=$(mktemp -d -t nain4-recompile-XXXXXX) test_dir=$(dirname "$(readlink -f "$0")") From 61b7ae534baeac732f43c44fe773fee6832da709 Mon Sep 17 00:00:00 2001 From: Jacek Generowicz Date: Thu, 17 Aug 2023 15:27:39 +0200 Subject: [PATCH 15/16] Revert to using tag v0.1.8 in client_fetch_content --- client_side_tests/client_fetch_content/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client_side_tests/client_fetch_content/CMakeLists.txt b/client_side_tests/client_fetch_content/CMakeLists.txt index 1d47b215..72d1e44c 100644 --- a/client_side_tests/client_fetch_content/CMakeLists.txt +++ b/client_side_tests/client_fetch_content/CMakeLists.txt @@ -10,7 +10,7 @@ set(FETCHCONTENT_UPDATES_DISCONNECTED ON CACHE BOOL "Cache package contents to a FetchContent_Declare( Nain4 GIT_REPOSITORY https://github.com/jacg/nain4.git - GIT_TAG origin/fix-darwin + GIT_TAG v0.1.8 # make sure that no other nain4 installation is used OVERRIDE_FIND_PACKAGE SOURCE_SUBDIR nain4 From 2b0615cce61070ad54a9df738a91151ad2209845 Mon Sep 17 00:00:00 2001 From: Jacek Generowicz Date: Thu, 17 Aug 2023 18:57:56 +0200 Subject: [PATCH 16/16] Bump tag to v0.1.9 in client_fetch_content test --- client_side_tests/client_fetch_content/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client_side_tests/client_fetch_content/CMakeLists.txt b/client_side_tests/client_fetch_content/CMakeLists.txt index 72d1e44c..0bb086ea 100644 --- a/client_side_tests/client_fetch_content/CMakeLists.txt +++ b/client_side_tests/client_fetch_content/CMakeLists.txt @@ -10,7 +10,7 @@ set(FETCHCONTENT_UPDATES_DISCONNECTED ON CACHE BOOL "Cache package contents to a FetchContent_Declare( Nain4 GIT_REPOSITORY https://github.com/jacg/nain4.git - GIT_TAG v0.1.8 + GIT_TAG v0.1.9 # make sure that no other nain4 installation is used OVERRIDE_FIND_PACKAGE SOURCE_SUBDIR nain4