tests.stdenv.structuredAttrsByDefault.test-cc-wrapper-substitutions: fix on darwin (#406062)

This commit is contained in:
Philip Taron
2025-05-15 20:14:56 -07:00
committed by GitHub
6 changed files with 29 additions and 20 deletions
@@ -59,7 +59,7 @@ stdenv.mkDerivation {
dontUnpack = true;
# Additional flags passed to pkg-config.
addFlags = optional stdenv.targetPlatform.isStatic "--static";
env.addFlags = optionalString stdenv.targetPlatform.isStatic "--static";
installPhase =
''
@@ -34,8 +34,10 @@ stdenv.mkDerivation {
substituteAll ${./darwin-sign-fixup.sh} $out/nix-support/setup-hooks.sh
'';
inherit (builtins) storeDir;
shell = lib.getBin shell + (shell.shellPath or "");
signingUtils = if darwinCodeSign then signingUtils else null;
env = {
inherit (builtins) storeDir;
shell = lib.getBin shell + (shell.shellPath or "");
} // lib.optionalAttrs darwinCodeSign { inherit signingUtils; };
meta.mainProgram = "remove-references-to";
}
@@ -7,7 +7,7 @@ index d2c7db4..dc107b3 100644
TO_BIN= lua luac
TO_INC= lua.h luaconf.h lualib.h lauxlib.h lua.hpp
-TO_LIB= liblua.a
+TO_LIB= liblua.${version}.dylib
+TO_LIB= liblua.${pkgversion}.dylib
TO_MAN= lua.1 luac.1
# Lua version and release.
@@ -15,7 +15,7 @@ index d2c7db4..dc107b3 100644
cd src && $(INSTALL_DATA) $(TO_INC) $(INSTALL_INC)
cd src && $(INSTALL_DATA) $(TO_LIB) $(INSTALL_LIB)
cd doc && $(INSTALL_DATA) $(TO_MAN) $(INSTALL_MAN)
+ ln -s -f liblua.${version}.dylib $(INSTALL_LIB)/liblua.${luaversion}.dylib
+ ln -s -f liblua.${pkgversion}.dylib $(INSTALL_LIB)/liblua.${luaversion}.dylib
+ ln -s -f liblua.${luaversion}.dylib $(INSTALL_LIB)/liblua.dylib
uninstall:
@@ -29,7 +29,7 @@ index 7b4b2b7..25001e5 100644
PLATS= aix ansi bsd freebsd generic linux macosx mingw posix solaris
-LUA_A= liblua.a
+LUA_A= liblua.${version}.dylib
+LUA_A= liblua.${pkgversion}.dylib
CORE_O= lapi.o lcode.o lctype.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o \
lmem.o lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o \
ltm.o lundump.o lvm.o lzio.o
@@ -39,14 +39,14 @@ index 7b4b2b7..25001e5 100644
$(LUA_A): $(BASE_O)
- $(AR) $@ $(BASE_O)
- $(RANLIB) $@
+ $(CC) -dynamiclib -install_name $(out)/lib/liblua.${version}.dylib \
+ -compatibility_version ${version} -current_version ${version} \
+ -o liblua.${version}.dylib $^
+ $(CC) -dynamiclib -install_name $(out)/lib/liblua.${pkgversion}.dylib \
+ -compatibility_version ${pkgversion} -current_version ${pkgversion} \
+ -o liblua.${pkgversion}.dylib $^
$(LUA_T): $(LUA_O) $(LUA_A)
- $(CC) -o $@ $(LDFLAGS) $(LUA_O) $(LUA_A) $(LIBS)
+ $(CC) -fno-common $(MYLDFLAGS) \
+ -o $@ $(LUA_O) $(LUA_A) -L. -llua.${version} $(LIBS)
+ -o $@ $(LUA_O) $(LUA_A) -L. -llua.${pkgversion} $(LIBS)
$(LUAC_T): $(LUAC_O) $(LUA_A)
$(CC) -o $@ $(LDFLAGS) $(LUAC_O) $(LUA_A) $(LIBS)
@@ -5,7 +5,7 @@
TO_BIN= lua luac
TO_INC= lua.h luaconf.h lualib.h lauxlib.h lua.hpp
-TO_LIB= liblua.a
+TO_LIB= liblua.${version}.dylib
+TO_LIB= liblua.${pkgversion}.dylib
TO_MAN= lua.1 luac.1
# Lua version and release.
@@ -13,7 +13,7 @@
cd src && $(INSTALL_DATA) $(TO_INC) $(INSTALL_INC)
cd src && $(INSTALL_DATA) $(TO_LIB) $(INSTALL_LIB)
cd doc && $(INSTALL_DATA) $(TO_MAN) $(INSTALL_MAN)
+ ln -s -f liblua.${version}.dylib $(INSTALL_LIB)/liblua.${luaversion}.dylib
+ ln -s -f liblua.${pkgversion}.dylib $(INSTALL_LIB)/liblua.${luaversion}.dylib
+ ln -s -f liblua.${luaversion}.dylib $(INSTALL_LIB)/liblua.dylib
uninstall:
@@ -25,7 +25,7 @@
PLATS= guess aix bsd c89 freebsd generic linux linux-readline macosx mingw posix solaris
-LUA_A= liblua.a
+LUA_A= liblua.${version}.dylib
+LUA_A= liblua.${pkgversion}.dylib
CORE_O= lapi.o lcode.o lctype.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o lundump.o lvm.o lzio.o
LIB_O= lauxlib.o lbaselib.o lcorolib.o ldblib.o liolib.o lmathlib.o loadlib.o loslib.o lstrlib.o ltablib.o lutf8lib.o linit.o
BASE_O= $(CORE_O) $(LIB_O) $(MYOBJS)
@@ -35,14 +35,14 @@
$(LUA_A): $(BASE_O)
- $(AR) $@ $(BASE_O)
- $(RANLIB) $@
+ $(CC) -dynamiclib -install_name $(out)/lib/liblua.${version}.dylib \
+ -compatibility_version ${version} -current_version ${version} \
+ -o liblua.${version}.dylib $^
+ $(CC) -dynamiclib -install_name $(out)/lib/liblua.${pkgversion}.dylib \
+ -compatibility_version ${pkgversion} -current_version ${pkgversion} \
+ -o liblua.${pkgversion}.dylib $^
$(LUA_T): $(LUA_O) $(LUA_A)
- $(CC) -o $@ $(LDFLAGS) $(LUA_O) $(LUA_A) $(LIBS)
+ $(CC) -fno-common $(MYLDFLAGS) \
+ -o $@ $(LUA_O) $(LUA_A) -L. -llua.${version} $(LIBS)
+ -o $@ $(LUA_O) $(LUA_A) -L. -llua.${pkgversion} $(LIBS)
$(LUAC_T): $(LUAC_O) $(LUA_A)
$(CC) -o $@ $(LDFLAGS) $(LUAC_O) $(LUA_A) $(LIBS)
@@ -99,6 +99,11 @@ stdenv.mkDerivation (
cat ${./lua-dso.make} >> src/Makefile
'';
env = {
inherit luaversion;
pkgversion = version;
};
# see configurePhase for additional flags (with space)
makeFlags = [
"INSTALL_TOP=${placeholder "out"}"
@@ -20,6 +20,8 @@ stdenv.mkDerivation {
'';
# Substituted variables
inherit sigtool;
codesignAllocate = "${cctools}/bin/${cctools.targetPrefix}codesign_allocate";
env = {
inherit sigtool;
codesignAllocate = "${cctools}/bin/${cctools.targetPrefix}codesign_allocate";
};
}