2
0
Fork 0

Patch Genode upstream to use conventional library names

Use library names that are compatible with legacy software.
nix
Emery Hemingway 3 years ago
parent 75615fac16
commit 32d65d2f41

@ -124,7 +124,7 @@ in rec {
let
f = head: input:
if hasAttr "manifest" input then
"${head},${input.pname}=${input.manifest}"
"${head},${nixpkgs.lib.getName input}=${input.manifest}"
else
abort "${input.pname} does not have a manifest";
in (foldl' f "{" inputs) + "}";

@ -1,27 +1,31 @@
# SPDX-License-Identifier: CC0-1.0
{ genodeSources, genodeBase }:
{ genodeSources, genodeBase, writeText }:
genodeSources.buildUpstream {
name = "libc";
outputs = [ "out" "dev" ];
targets = [ "LIB=libm" ];
portInputs = [ genodeSources.ports.libc ];
genodeSources.buildDepot {
name = "posix";
propagatedBuildInputs = [ genodeBase ];
LIBC_PORT = genodeSources.ports.libc;
portInputs = [ genodeSources.ports.libc ];
preInstall =
# Take the libc ABI stubs rather than the actual libc.
# The libc needs a lot of work and we can't afford to
# rebuild the toolchain for every fix.
''
find depot -name libc.abi.so -exec install -D {} "''${!outputLib}/libc.so" \;
'';
postInstall = ''
mkdir -p $dev/include
pushd $LIBC_PORT/*
local headerDir="''${!outputDev}/include"
mkdir -p "$headerDir"
pushd ${genodeSources.ports.libc}/*
cp -r \
include/libc/* \
include/openlibm/* \
$GENODE_DIR/repos/libports/include/libc \
$dev/include/
"$headerDir"
for spec in ${toString genodeSources.specs}; do
dir=include/spec/$spec/libc
if [ -d $dir ]; then
cp -r $dir/* $dev/include/
cp -r $dir/* "$headerDir"
fi
done
popd

@ -0,0 +1,125 @@
commit 91ad094b581afde72199de1029fdd0ff3103d731
Author: Emery Hemingway <ehmry@posteo.net>
Date: Tue May 5 21:39:21 2020 +0530
Produce libraries with conventional names
diff --git a/repos/base/mk/dep_lib.mk b/repos/base/mk/dep_lib.mk
index b3c980c906..385318bd46 100644
--- a/repos/base/mk/dep_lib.mk
+++ b/repos/base/mk/dep_lib.mk
@@ -142,8 +142,8 @@ endif
echo " DEBUG_DIR=\$$(DEBUG_DIR)"; \
echo "") >> $(LIB_DEP_FILE)
ifdef SHARED_LIB
- @(echo "SO_NAME($(LIB)) := $(LIB).lib.so"; \
- echo "") >> $(LIB_DEP_FILE)
+ @(echo "SO_NAME($(LIB)) := lib$(LIB).so"; \
+ echo "") | sed -e 's/libld.so/ld.lib.so/' -e 's/liblib/lib/' >> $(LIB_DEP_FILE)
else
@(echo "ARCHIVE_NAME($(LIB)) := $(LIB).lib.a"; \
echo "") >> $(LIB_DEP_FILE)
diff --git a/repos/base/mk/dep_prg.mk b/repos/base/mk/dep_prg.mk
index 190dd92aa1..6611d05d2a 100644
--- a/repos/base/mk/dep_prg.mk
+++ b/repos/base/mk/dep_prg.mk
@@ -93,7 +93,7 @@ endif
# if the target does not depend on any library with unsatisfied build
# requirements. In such a case, the target cannot be linked anyway.
#
- @(echo "ifeq (\$$(filter \$$(DEP_A_$(TARGET).prg:.lib.a=) \$$(DEP_SO_$(TARGET).prg:.lib.so=) $(LIBS),\$$(INVALID_DEPS)),)"; \
+ @(echo "ifeq (\$$(filter \$$(DEP_A_$(TARGET).prg:.lib.a=) \$$(patsubst lib%.lib.so,%,$(DEP_SO_$(TARGET).prg)) $(LIBS),\$$(INVALID_DEPS)),)"; \
echo "all: $(TARGET).prg"; \
echo "endif") >> $(LIB_DEP_FILE)
#
diff --git a/repos/base/mk/generic.mk b/repos/base/mk/generic.mk
index d551ac205b..e23fade62f 100644
--- a/repos/base/mk/generic.mk
+++ b/repos/base/mk/generic.mk
@@ -129,7 +129,7 @@ binary_%.o: %
# This is a problem in situations where the undefined symbol is resolved by an
# archive rather than the target. I.e., when linking posix.lib.a (which
# provides 'Libc::Component::construct'), the 'construct' function is merely
-# referenced by the libc.lib.so's 'Component::construct' function. But this
+# referenced by the libc.so's 'Component::construct' function. But this
# reference apparently does not suffice to keep the posix.lib.a's symbol. By
# adding a hard dependency, we force the linker to resolve the symbol and don't
# drop posix.lib.a.
@@ -164,12 +164,17 @@ endif
# time a user of the library is linked, the ABI stub should be used instead of
# the library.
#
-select_so = $(firstword $(wildcard $(LIB_CACHE_DIR)/$(1:.lib.so=)/$(1:.lib.so=).abi.so \
- $(LIB_CACHE_DIR)/$(1:.lib.so=)/$(1:.lib.so=).lib.so))
+select_so = $(firstword $(wildcard \
+ $(LIB_CACHE_DIR)/$(patsubst lib%.so,%,$1)/$(patsubst lib%.so,%,$1).abi.so \
+ $(LIB_CACHE_DIR)/$(patsubst lib%.so,%,$1)/$(1) \
+ $(LIB_CACHE_DIR)/$(patsubst %.so,%,$1)/$(1) \
+ $(LIB_CACHE_DIR)/$(1:.lib.so=)/$(1:.lib.so=).abi.so \
+ $(LIB_CACHE_DIR)/$(1:.lib.so=)/$(1:.lib.so=).lib.so \
+ $(LIB_CACHE_DIR)/$(1:.so=)/$(1:.so=).abi.so ))
ifneq ($(filter-out $(foreach s,$(SHARED_LIBS),$(realpath $s)), \
$(foreach s,$(SHARED_LIBS),$(call select_so,$s))),)
.PHONY: $(SHARED_LIBS)
endif
$(SHARED_LIBS):
- $(VERBOSE)ln -sf $(call select_so,$@) $@
+ $(VERBOSE)ln -sf $(call select_so,$@) $(patsubst liblib%,lib%,$@)
diff --git a/repos/base/mk/lib.mk b/repos/base/mk/lib.mk
index c482457af6..7abae9ecdc 100644
--- a/repos/base/mk/lib.mk
+++ b/repos/base/mk/lib.mk
@@ -123,14 +123,20 @@ message:
include $(BASE_DIR)/mk/generic.mk
#
-# Name of <libname>.lib.a or <libname>.lib.so file to create
+# Name of <libname>.lib.a or lib<libname>.so file to create
#
# Skip the creation and installation of an .so file if there are no
# ingredients. This is the case if the library is present as ABI only.
#
ifdef SHARED_LIB
ifneq ($(sort $(OBJECTS) $(LIBS)),)
- LIB_SO := $(addsuffix .lib.so,$(LIB))
+ ifeq ($(LIB),ld)
+ LIB_SO := ld.lib.so
+ else ifeq ($(patsubst ld-%,ld-,$(LIB)),ld-)
+ LIB_SO := $(LIB).lib.so
+ else
+ LIB_SO := $(patsubst liblib%,lib%,$(patsubst %,lib%.so,$(LIB)))
+ endif
INSTALL_SO := $(INSTALL_DIR)/$(LIB_SO)
DEBUG_SO := $(DEBUG_DIR)/$(LIB_SO)
endif
@@ -150,7 +156,7 @@ ifneq ($(LIB_SO),)
endif
#
-# Trigger the creation of the <libname>.lib.a or <libname>.lib.so file
+# Trigger the creation of the <libname>.lib.a or lib<libname>.so file
#
LIB_TAG := $(addsuffix .lib.tag,$(LIB))
all: $(LIB_TAG)
@@ -202,7 +208,7 @@ STATIC_LIBS := $(sort $(foreach l,$(ARCHIVES:.lib.a=),$(LIB_CACHE_DIR)/$l/
STATIC_LIBS_BRIEF := $(subst $(LIB_CACHE_DIR),$$libs,$(STATIC_LIBS))
#
-# Rule to build the <libname>.lib.so file
+# Rule to build the lib<libname>.so file
#
# When linking the shared library, we have to link all shared sub libraries
# (LIB_SO_DEPS) to the library to store the library-dependency information in
diff --git a/repos/base/mk/prg.mk b/repos/base/mk/prg.mk
index 04caae01b2..8d64b0d34e 100644
--- a/repos/base/mk/prg.mk
+++ b/repos/base/mk/prg.mk
@@ -235,6 +235,6 @@ endif
clean_prg_objects:
$(MSG_CLEAN)$(PRG_REL_DIR)
$(VERBOSE)$(RM) -f $(OBJECTS) $(OBJECTS:.o=.d) $(TARGET) $(TARGET).stripped $(BINDER_SRC)
- $(VERBOSE)$(RM) -f *.d *.i *.ii *.s *.ali *.lib.so
+ $(VERBOSE)$(RM) -f *.d *.i *.ii *.s *.ali *.lib.so lib*.so
clean: clean_prg_objects

@ -25,8 +25,8 @@ let
url = "https://github.com/genodelabs/genode/archive/${version}.tar.gz";
hash = "sha256-ZY9ND6vDA9u127TAv87uOjPuLzRzBPyp5PzD6iM7uNI=";
};
nativeBuildInputs = [ expect gnumake tcl ];
patches = [ ./LIB.patch ];
configurePhase = ''
patchShebangs ./tool
substituteInPlace repos/base/etc/tools.conf \
@ -151,13 +151,13 @@ let
'';
});
buildDepot = { name, portInputs ? [ ], nativeBuildInputs ? [ ]
, enableParallelBuilding ? true, ... }@extraAttrs:
buildDepot = { name, apiOnly ? false, portInputs ? [ ]
, nativeBuildInputs ? [ ], ... }@extraAttrs:
stdenv'.mkDerivation (extraAttrs // {
pname = name;
inherit (genodeSources) version;
inherit enableParallelBuilding;
enableParallelBuilding = true;
nativeBuildInputs = [ binutils bison flex stdenv.cc tcl which ]
++ nativeBuildInputs;
@ -181,6 +181,7 @@ let
'';
STRIP_TARGET_CMD = "cp $< $@";
# defer strip until fixup phase
makefile = "tool/depot/create";
makeFlags = [
@ -188,13 +189,16 @@ let
# by default the build system will refuse to be useful
"FORCE=1"
"KEEP_BUILD_DIR=1"
"UPDATE_VERSIONS=1"
"VERBOSE="
];
installPhase = ''
runHook preInstall
find depot/genodelabs/bin -type f -exec install -Dt $out {} \;
rm -r depot/genodelabs/bin/${arch}/${name}/*\.build
find depot/genodelabs/bin/${arch}/${name} -type f -exec install -Dt "''${!outputBin}" {} \;
moveToOutput "lib*.so" "''${!outputLib}/lib"
runHook postInstall
'';

@ -44,6 +44,8 @@ with ports; {
vesa_drv.portInputs = [ libc x86emu ];
vfs.outputs = [ "out" "lib" ];
vfs_jitterentropy.portInputs = [ jitterentropy libc ];
vfs_lwip.portInputs = [ lwip ];
vfs_ttf.portInputs = [ libc stb ];

@ -13,6 +13,11 @@ let
set -eu
echo -n '[' >> $out
find $drv/ -type f -printf ',{mapKey= "%f",mapValue="%p"}' >> $out
${if builtins.elem "lib" drv.outputs then
''
find ${drv.lib}/ -type f -printf ',{mapKey= "%f",mapValue="%p"}' >> $out''
else
""}
echo -n ']' >> $out
'';
};

Loading…
Cancel
Save