From 9fae434553d6ff3ec931115b4d8e95bd9c548aa1 Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Mallo Date: Mon, 13 Mar 2023 16:08:38 +0100 Subject: [PATCH] Enable -fPIC in Nanos6 loader --- bsc/nanos6/default.nix | 2 ++ bsc/nanos6/fpic.patch | 57 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 bsc/nanos6/fpic.patch diff --git a/bsc/nanos6/default.nix b/bsc/nanos6/default.nix index aa5b1ea..c67d280 100644 --- a/bsc/nanos6/default.nix +++ b/bsc/nanos6/default.nix @@ -35,6 +35,8 @@ stdenv.mkDerivation rec { sha256 = "YGj/cubqXaNt4lR2CnSU+nXvi+SdB56EXLhfN/ufjHs="; }; + patches = [ ./fpic.patch ]; + prePatch = '' patchShebangs scripts/generate_config.sh ''; diff --git a/bsc/nanos6/fpic.patch b/bsc/nanos6/fpic.patch new file mode 100644 index 0000000..34e2cdf --- /dev/null +++ b/bsc/nanos6/fpic.patch @@ -0,0 +1,57 @@ +diff --git a/Makefile.am b/Makefile.am +index 5718226456dcf0e422200d1289a14816f51bd39d..c4d49a80f3899b6439184837555c03337b832018 100755 +--- a/Makefile.am ++++ b/Makefile.am +@@ -115,7 +115,7 @@ lib_LTLIBRARIES = \ + libnanos6-optimized-discrete-verbose.la \ + libnanos6-optimized-regions-verbose.la + +-noinst_LIBRARIES = libnanos6-main-wrapper.a libnanos6-library-mode.a ++noinst_LTLIBRARIES = libnanos6-main-wrapper.la libnanos6-library-mode.la + lib_OBJECTS = nanos6-main-wrapper.o nanos6-library-mode.o + + +@@ -139,7 +139,7 @@ if ANDROID + main_interception += loader/intercept-main-android.c + endif + +-libnanos6_main_wrapper_a_SOURCES = \ ++libnanos6_main_wrapper_la_SOURCES = \ + $(main_interception) \ + loader/api-versions.c \ + loader/api-versions.h \ +@@ -150,25 +150,27 @@ libnanos6_main_wrapper_a_SOURCES = \ + loader/main-wrapper.c \ + loader/main-wrapper.h + +-libnanos6_main_wrapper_a_CPPFLAGS = $(CUDA_CFLAGS) $(MPI_CXXFLAGS) $(MCMODEL_FLAGS) ++libnanos6_main_wrapper_la_CPPFLAGS = $(CUDA_CFLAGS) $(MPI_CXXFLAGS) $(MCMODEL_FLAGS) ++libnanos6_main_wrapper_la_LDFLAGS = -static + + +-nanos6-main-wrapper.o: libnanos6-main-wrapper.a +- $(AM_V_LD)$(LD) -r --whole-archive libnanos6-main-wrapper.a -o nanos6-main-wrapper.o ++nanos6-main-wrapper.o: libnanos6-main-wrapper.la ++ $(AM_V_LD)$(LD) -r --whole-archive $(top_builddir)/.libs/libnanos6-main-wrapper.a -o nanos6-main-wrapper.o + + +-libnanos6_library_mode_a_SOURCES = \ ++libnanos6_library_mode_la_SOURCES = \ + $(library_interception) \ + loader/api-versions.c \ + loader/api-versions.h \ + loader/device_strings.c \ + loader/library-mode-init.c + +-libnanos6_library_mode_a_CPPFLAGS = $(CUDA_CFLAGS) $(MPI_CXXFLAGS) $(MCMODEL_FLAGS) ++libnanos6_library_mode_la_CPPFLAGS = $(CUDA_CFLAGS) $(MPI_CXXFLAGS) $(MCMODEL_FLAGS) ++libnanos6_library_mode_la_LDFLAGS = -static + + +-nanos6-library-mode.o: libnanos6-library-mode.a +- $(AM_V_LD)$(LD) -r --whole-archive libnanos6-library-mode.a -o nanos6-library-mode.o ++nanos6-library-mode.o: libnanos6-library-mode.la ++ $(AM_V_LD)$(LD) -r --whole-archive $(top_builddir)/.libs/libnanos6-library-mode.a -o nanos6-library-mode.o + + + #