From 12d2821bf56be27d33b90f109220a342a11828ca Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Mon, 23 Jan 2023 15:34:53 +0000 Subject: [PATCH] treewide: remove -ldl linker flags With all libcs I'm aware of, libdl is now either empty (Glibc, musl, uclibc, illumos), a symlink to libc or equivalent (Apple), or does not exist (FreeBSD, NetBSD). So explicitly linking libdl now does nothing for the former platforms, and breaks the build for the latter platforms. With this patch I've removed -ldl from all overridden linker flags for all free packages in Nixpkgs. Everything still seems to build. --- pkgs/applications/audio/jack-rack/default.nix | 2 +- pkgs/applications/audio/jamin/default.nix | 2 -- pkgs/build-support/libredirect/default.nix | 6 +++--- pkgs/desktops/rox/rox-filer/default.nix | 2 +- pkgs/development/compilers/gcc/10/default.nix | 2 +- pkgs/development/compilers/gcc/11/default.nix | 2 +- pkgs/development/compilers/gcc/12/default.nix | 2 +- pkgs/development/compilers/gcc/6/default.nix | 2 +- pkgs/development/compilers/gcc/7/default.nix | 2 +- pkgs/development/compilers/gcc/8/default.nix | 2 +- pkgs/development/compilers/gcc/9/default.nix | 2 +- pkgs/development/compilers/tinycc/default.nix | 1 - pkgs/games/eboard/default.nix | 1 - pkgs/servers/mail/exim/default.nix | 4 ++-- pkgs/servers/monitoring/nagios/default.nix | 1 - pkgs/servers/nosql/influxdb/default.nix | 2 +- pkgs/servers/nosql/influxdb2/default.nix | 2 +- pkgs/servers/openafs/1.8/default.nix | 1 - pkgs/tools/graphics/argyllcms/default.nix | 2 +- pkgs/tools/networking/dsniff/default.nix | 2 +- 20 files changed, 18 insertions(+), 24 deletions(-) diff --git a/pkgs/applications/audio/jack-rack/default.nix b/pkgs/applications/audio/jack-rack/default.nix index 420c11562e2a..8cf55289b2f3 100644 --- a/pkgs/applications/audio/jack-rack/default.nix +++ b/pkgs/applications/audio/jack-rack/default.nix @@ -8,7 +8,7 @@ stdenv.mkDerivation rec { }; nativeBuildInputs = [ pkg-config ]; buildInputs = [ libjack2 ladspaH gtk2 alsa-lib libxml2 lrdf ]; - NIX_LDFLAGS = "-ldl -lm -lpthread"; + NIX_LDFLAGS = "-lm -lpthread"; meta = { description = ''An effects "rack" for the JACK low latency audio API''; diff --git a/pkgs/applications/audio/jamin/default.nix b/pkgs/applications/audio/jamin/default.nix index 70cb4d7f1109..36b6345c0f11 100644 --- a/pkgs/applications/audio/jamin/default.nix +++ b/pkgs/applications/audio/jamin/default.nix @@ -21,8 +21,6 @@ stdenv.mkDerivation rec { # `l_notebook1'; jamin-callbacks.o:/build/jamin-0.95.0/src/hdeq.h:64: first defined here NIX_CFLAGS_COMPILE = "-fcommon"; - NIX_LDFLAGS = "-ldl"; - postInstall = '' wrapProgram $out/bin/jamin --set LADSPA_PATH ${ladspaPlugins}/lib/ladspa ''; diff --git a/pkgs/build-support/libredirect/default.nix b/pkgs/build-support/libredirect/default.nix index b5eb21e5ba4b..6e2de7fa11b0 100644 --- a/pkgs/build-support/libredirect/default.nix +++ b/pkgs/build-support/libredirect/default.nix @@ -46,14 +46,14 @@ else stdenv.mkDerivation rec { -L${llvmPackages_13.clang.libc}/lib \ -Wl,-install_name,$libName \ -Wall -std=c99 -O3 -fPIC libredirect.c \ - -ldl -shared -o "$libName" + -shared -o "$libName" '' else if stdenv.isDarwin then '' $CC -Wall -std=c99 -O3 -fPIC libredirect.c \ -Wl,-install_name,$out/lib/$libName \ - -ldl -shared -o "$libName" + -shared -o "$libName" '' else '' $CC -Wall -std=c99 -O3 -fPIC libredirect.c \ - -ldl -shared -o "$libName" + -shared -o "$libName" ''} if [ -n "$doInstallCheck" ]; then diff --git a/pkgs/desktops/rox/rox-filer/default.nix b/pkgs/desktops/rox/rox-filer/default.nix index e26c90592252..b05be287a89d 100644 --- a/pkgs/desktops/rox/rox-filer/default.nix +++ b/pkgs/desktops/rox/rox-filer/default.nix @@ -24,7 +24,7 @@ stdenv.mkDerivation rec { wrapGAppsHook ]; buildInputs = [ libxml2 gtk shared-mime-info libSM ]; - NIX_LDFLAGS = "-ldl -lm"; + NIX_LDFLAGS = "-lm"; patches = [ ./rox-filer-2.11-in-source-build.patch diff --git a/pkgs/development/compilers/gcc/10/default.nix b/pkgs/development/compilers/gcc/10/default.nix index 2751501901f2..731bcd7c39cd 100644 --- a/pkgs/development/compilers/gcc/10/default.nix +++ b/pkgs/development/compilers/gcc/10/default.nix @@ -181,7 +181,7 @@ stdenv.mkDerivation ({ depsTargetTarget = optional (!crossStageStatic && threadsCross != {} && threadsCross.package != null) threadsCross.package; - NIX_LDFLAGS = lib.optionalString hostPlatform.isSunOS "-lm -ldl"; + NIX_LDFLAGS = lib.optionalString hostPlatform.isSunOS "-lm"; preConfigure = (import ../common/pre-configure.nix { inherit lib; diff --git a/pkgs/development/compilers/gcc/11/default.nix b/pkgs/development/compilers/gcc/11/default.nix index 265e696523da..477c033c2bad 100644 --- a/pkgs/development/compilers/gcc/11/default.nix +++ b/pkgs/development/compilers/gcc/11/default.nix @@ -185,7 +185,7 @@ stdenv.mkDerivation ({ depsTargetTarget = optional (!crossStageStatic && threadsCross != {} && threadsCross.package != null) threadsCross.package; - NIX_LDFLAGS = lib.optionalString hostPlatform.isSunOS "-lm -ldl"; + NIX_LDFLAGS = lib.optionalString hostPlatform.isSunOS "-lm"; preConfigure = (import ../common/pre-configure.nix { inherit lib; diff --git a/pkgs/development/compilers/gcc/12/default.nix b/pkgs/development/compilers/gcc/12/default.nix index 7e1847ebba98..3ba5991a6b8c 100644 --- a/pkgs/development/compilers/gcc/12/default.nix +++ b/pkgs/development/compilers/gcc/12/default.nix @@ -228,7 +228,7 @@ stdenv.mkDerivation ({ depsTargetTarget = optional (!crossStageStatic && threadsCross != {}) threadsCross.package; - NIX_LDFLAGS = lib.optionalString hostPlatform.isSunOS "-lm -ldl"; + NIX_LDFLAGS = lib.optionalString hostPlatform.isSunOS "-lm"; preConfigure = (import ../common/pre-configure.nix { diff --git a/pkgs/development/compilers/gcc/6/default.nix b/pkgs/development/compilers/gcc/6/default.nix index 66b53c6d5b5e..b3ee702e31b8 100644 --- a/pkgs/development/compilers/gcc/6/default.nix +++ b/pkgs/development/compilers/gcc/6/default.nix @@ -219,7 +219,7 @@ stdenv.mkDerivation ({ depsTargetTarget = optional (!crossStageStatic && threadsCross != {}) threadsCross.package; - NIX_LDFLAGS = lib.optionalString hostPlatform.isSunOS "-lm -ldl"; + NIX_LDFLAGS = lib.optionalString hostPlatform.isSunOS "-lm"; preConfigure = import ../common/pre-configure.nix { inherit lib; diff --git a/pkgs/development/compilers/gcc/7/default.nix b/pkgs/development/compilers/gcc/7/default.nix index 8fd990f95ffb..38eeec063033 100644 --- a/pkgs/development/compilers/gcc/7/default.nix +++ b/pkgs/development/compilers/gcc/7/default.nix @@ -187,7 +187,7 @@ stdenv.mkDerivation ({ depsTargetTarget = optional (!crossStageStatic && threadsCross != {}) threadsCross.package; NIX_CFLAGS_COMPILE = lib.optionalString (stdenv.cc.isClang && langFortran) "-Wno-unused-command-line-argument"; - NIX_LDFLAGS = lib.optionalString hostPlatform.isSunOS "-lm -ldl"; + NIX_LDFLAGS = lib.optionalString hostPlatform.isSunOS "-lm"; preConfigure = import ../common/pre-configure.nix { inherit lib; diff --git a/pkgs/development/compilers/gcc/8/default.nix b/pkgs/development/compilers/gcc/8/default.nix index 2dc141b529fc..4072ca9a533c 100644 --- a/pkgs/development/compilers/gcc/8/default.nix +++ b/pkgs/development/compilers/gcc/8/default.nix @@ -169,7 +169,7 @@ stdenv.mkDerivation ({ depsTargetTarget = optional (!crossStageStatic && threadsCross != {}) threadsCross.package; - NIX_LDFLAGS = lib.optionalString hostPlatform.isSunOS "-lm -ldl"; + NIX_LDFLAGS = lib.optionalString hostPlatform.isSunOS "-lm"; preConfigure = import ../common/pre-configure.nix { inherit lib; diff --git a/pkgs/development/compilers/gcc/9/default.nix b/pkgs/development/compilers/gcc/9/default.nix index 9b5f4504db8e..36fea987ae22 100644 --- a/pkgs/development/compilers/gcc/9/default.nix +++ b/pkgs/development/compilers/gcc/9/default.nix @@ -182,7 +182,7 @@ stdenv.mkDerivation ({ depsTargetTarget = optional (!crossStageStatic && threadsCross != {}) threadsCross.package; - NIX_LDFLAGS = lib.optionalString hostPlatform.isSunOS "-lm -ldl"; + NIX_LDFLAGS = lib.optionalString hostPlatform.isSunOS "-lm"; preConfigure = import ../common/pre-configure.nix { inherit lib; diff --git a/pkgs/development/compilers/tinycc/default.nix b/pkgs/development/compilers/tinycc/default.nix index 159b1827fc8f..ed1d7fc57a64 100644 --- a/pkgs/development/compilers/tinycc/default.nix +++ b/pkgs/development/compilers/tinycc/default.nix @@ -38,7 +38,6 @@ stdenv.mkDerivation rec { "-L${variables.libdir}" "-Wl,--rpath ${variables.libdir}" "-ltcc" - "-ldl" ]; variables = rec { prefix = "${placeholder "out"}"; diff --git a/pkgs/games/eboard/default.nix b/pkgs/games/eboard/default.nix index 293811e9b040..81bc6d365a0c 100644 --- a/pkgs/games/eboard/default.nix +++ b/pkgs/games/eboard/default.nix @@ -21,7 +21,6 @@ stdenv.mkDerivation rec { ''; NIX_CFLAGS_COMPILE = "-fpermissive"; - NIX_LDFLAGS = "-ldl"; meta = { homepage = "http://www.bergo.eng.br/eboard/"; diff --git a/pkgs/servers/mail/exim/default.nix b/pkgs/servers/mail/exim/default.nix index cd407ef37ec7..1a911668a540 100644 --- a/pkgs/servers/mail/exim/default.nix +++ b/pkgs/servers/mail/exim/default.nix @@ -64,8 +64,8 @@ stdenv.mkDerivation rec { ${lib.optionalString enableMySQL '' s:^# \(LOOKUP_MYSQL=yes\)$:\1: s:^# \(LOOKUP_MYSQL_PC=libmysqlclient\)$:\1: - s:^\(LOOKUP_LIBS\)=\(.*\):\1=\2 -lmysqlclient -L${libmysqlclient}/lib/mysql -lssl -ldl -lm -lpthread -lz: - s:^# \(LOOKUP_LIBS\)=.*:\1=-lmysqlclient -L${libmysqlclient}/lib/mysql -lssl -ldl -lm -lpthread -lz: + s:^\(LOOKUP_LIBS\)=\(.*\):\1=\2 -lmysqlclient -L${libmysqlclient}/lib/mysql -lssl -lm -lpthread -lz: + s:^# \(LOOKUP_LIBS\)=.*:\1=-lmysqlclient -L${libmysqlclient}/lib/mysql -lssl -lm -lpthread -lz: s:^# \(LOOKUP_INCLUDE\)=.*:\1=-I${libmysqlclient.dev}/include/mysql/: ''} ${lib.optionalString enableAuthDovecot '' diff --git a/pkgs/servers/monitoring/nagios/default.nix b/pkgs/servers/monitoring/nagios/default.nix index a58ec2bf7b29..edf82742bc53 100644 --- a/pkgs/servers/monitoring/nagios/default.nix +++ b/pkgs/servers/monitoring/nagios/default.nix @@ -15,7 +15,6 @@ stdenv.mkDerivation rec { configureFlags = [ "--localstatedir=/var/lib/nagios" ]; buildFlags = [ "all" ]; - CFLAGS = "-ldl"; # Do not create /var directories preInstall = '' diff --git a/pkgs/servers/nosql/influxdb/default.nix b/pkgs/servers/nosql/influxdb/default.nix index 185c246e6fac..a80975926e8d 100644 --- a/pkgs/servers/nosql/influxdb/default.nix +++ b/pkgs/servers/nosql/influxdb/default.nix @@ -33,7 +33,7 @@ let Version: ${libflux_version} Description: Library for the InfluxData Flux engine Cflags: -I/out/include - Libs: -L/out/lib -lflux -ldl -lpthread + Libs: -L/out/lib -lflux -lpthread ''; passAsFile = [ "pkgcfg" ]; postInstall = '' diff --git a/pkgs/servers/nosql/influxdb2/default.nix b/pkgs/servers/nosql/influxdb2/default.nix index 41bba89996bf..4f86cc4da530 100644 --- a/pkgs/servers/nosql/influxdb2/default.nix +++ b/pkgs/servers/nosql/influxdb2/default.nix @@ -51,7 +51,7 @@ let Version: ${libflux_version} Description: Library for the InfluxData Flux engine Cflags: -I/out/include - Libs: -L/out/lib -lflux -ldl -lpthread + Libs: -L/out/lib -lflux -lpthread ''; passAsFile = [ "pkgcfg" ]; postInstall = '' diff --git a/pkgs/servers/openafs/1.8/default.nix b/pkgs/servers/openafs/1.8/default.nix index d6e2f20ecdbe..8ebed1c27464 100644 --- a/pkgs/servers/openafs/1.8/default.nix +++ b/pkgs/servers/openafs/1.8/default.nix @@ -89,7 +89,6 @@ stdenv.mkDerivation { ) '' + optionalString withTsm '' export XBSA_CFLAGS="-Dxbsa -DNEW_XBSA -I${tsm-client}/lib64/sample -DXBSA_TSMLIB=\\\"${tsm-client}/lib64/libApiTSM64.so\\\"" - export XBSA_XLIBS="-ldl" ''; buildFlags = [ "all_nolibafs" ]; diff --git a/pkgs/tools/graphics/argyllcms/default.nix b/pkgs/tools/graphics/argyllcms/default.nix index 2b17fa796e84..f06021693504 100644 --- a/pkgs/tools/graphics/argyllcms/default.nix +++ b/pkgs/tools/graphics/argyllcms/default.nix @@ -85,7 +85,7 @@ stdenv.mkDerivation rec { LINKFLAGS += ${lib.concatStringsSep " " (map (x: "-L${x}/lib") buildInputs)} - -ldl -lrt -lX11 -lXext -lXxf86vm -lXinerama -lXrandr -lXau -lXdmcp -lXss + -lrt -lX11 -lXext -lXxf86vm -lXinerama -lXrandr -lXau -lXdmcp -lXss -ljpeg -ltiff -lpng -lssl ; ''; in '' diff --git a/pkgs/tools/networking/dsniff/default.nix b/pkgs/tools/networking/dsniff/default.nix index 8e641ec83e73..5d0c92f2bfb5 100644 --- a/pkgs/tools/networking/dsniff/default.nix +++ b/pkgs/tools/networking/dsniff/default.nix @@ -60,7 +60,7 @@ in gcc9Stdenv.mkDerivation rec { nativeBuildInputs = [ autoreconfHook rpcsvc-proto ]; buildInputs = [ glib pcap libtirpc libnsl ]; - NIX_CFLAGS_LINK = "-lglib-2.0 -lpthread -ldl -ltirpc"; + NIX_CFLAGS_LINK = "-lglib-2.0 -lpthread -ltirpc"; NIX_CFLAGS_COMPILE = [ "-I${libtirpc.dev}/include/tirpc" ]; postPatch = '' for patch in debian/patches/*.patch; do