2
0
Fork 0

Return to *.lib.so library naming convention

posix
Emery Hemingway 2 years ago
parent df806832d6
commit a48dc08001
  1. 8
      overlay/default.nix
  2. 76
      overlay/libtool/genode.patch
  3. 2
      overlay/llvm-8/default.nix
  4. 2
      overlay/llvm-8/lld/default.nix
  5. 64
      overlay/llvm-8/lld/genode.patch
  6. 27
      packages/default.nix
  7. 208
      packages/genodelabs/LIB.patch
  8. 15
      packages/genodelabs/default.nix

@ -9,6 +9,9 @@ let
overrideHostAttrs = drv: f:
if hostPlatform.isGenode then drv.overrideAttrs f else drv;
overrideTarget = drv: f:
if targetPlatform.isGenode then drv.override f else drv;
overrideTargetAttrs = drv: f:
if targetPlatform.isGenode then drv.overrideAttrs f else drv;
@ -78,6 +81,11 @@ in {
else
prev.libcCrossChooser name;
libtool = overrideTargetAttrs libtool (attrs: {
nativeBuildInputs = attrs.nativeBuildInputs ++ [ autoconf automake115x ];
patches = ./libtool/genode.patch;
});
llvmPackages_8 = callPackage ./llvm-8 ({
inherit (stdenvAdapters) overrideCC;
inherit (targetPackages.genodeSources) genodeBase;

@ -0,0 +1,76 @@
commit d9cf21a6ff7652bca277e280e7820d082fbdc5a1
Author: Emery Hemingway <ehmry@posteo.net>
Date: Thu Oct 29 18:47:44 2020 +0100
libtool: Genode OS support
diff --git a/m4/libtool.m4 b/m4/libtool.m4
index f2d1f398..2041eefd 100644
--- a/m4/libtool.m4
+++ b/m4/libtool.m4
@@ -2722,6 +2722,17 @@ freebsd* | dragonfly*)
esac
;;
+genode*)
+ version_type=none
+ need_lib_prefix=no
+ need_version=no
+ dynamic_linker="$host_os ld.lib.so"
+ library_names_spec='$name.lib$shared_ext'
+ soname_spec='$name.lib$shared_ext'
+ sys_lib_dlsearch_path_spec=
+ hardcode_into_libs=yes
+ ;;
+
haiku*)
version_type=linux # correct to gnu/linux during the next big refactor
need_lib_prefix=no
@@ -3526,6 +3537,10 @@ freebsd* | dragonfly*)
fi
;;
+genode*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
haiku*)
lt_cv_deplibs_check_method=pass_all
;;
@@ -4684,6 +4699,11 @@ m4_if([$1], [CXX], [
esac
;;
+ genode*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+ ;;
+
hpux9* | hpux10* | hpux11*)
_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
# PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
@@ -5680,6 +5700,13 @@ _LT_EOF
_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
;;
+ genode*)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ ;;
+
hpux9*)
if test yes = "$GCC"; then
_LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared $pic_flag $wl+b $wl$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib'
@@ -6791,6 +6818,10 @@ if test yes != "$_lt_caught_CXX_error"; then
_LT_TAGVAR(ld_shlibs, $1)=yes
;;
+ genode*)
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+
haiku*)
_LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
_LT_TAGVAR(link_all_deplibs, $1)=yes

@ -79,7 +79,7 @@ let
extraBuildCommands = mkExtraBuildCommands cc;
};
lld = callPackage ./lld.nix {};
lld = callPackage ./lld {};
lldb = callPackage ./lldb.nix {};

@ -21,6 +21,8 @@ stdenv.mkDerivation {
outputs = [ "out" "dev" ];
patches = stdenv.lib.optional (stdenv.targetPlatform.isGenode) ./genode.patch;
enableParallelBuilding = true;
postInstall = ''

@ -0,0 +1,64 @@
diff --git a/ELF/Driver.cpp b/ELF/Driver.cpp
index bce9d944a..cf42193f9 100644
--- a/ELF/Driver.cpp
+++ b/ELF/Driver.cpp
@@ -235,12 +235,8 @@ void LinkerDriver::addFile(StringRef Path, bool WithLOption) {
// file has a DT_SONAME or not because we haven't parsed it yet.
// Here, we set the default soname for the file because we might
// need it later.
- //
- // If a file was specified by -lfoo, the directory part is not
- // significant, as a user did not specify it. This behavior is
- // compatible with GNU.
Files.push_back(
- createSharedFile(MBRef, WithLOption ? path::filename(Path) : Path));
+ createSharedFile(MBRef, Path));
return;
case file_magic::bitcode:
case file_magic::elf_relocatable:
diff --git a/ELF/DriverUtils.cpp b/ELF/DriverUtils.cpp
index e51d02e38..259ea8053 100644
--- a/ELF/DriverUtils.cpp
+++ b/ELF/DriverUtils.cpp
@@ -194,14 +194,16 @@ std::string elf::createResponseFile(const opt::InputArgList &Args) {
// Find a file by concatenating given paths. If a resulting path
// starts with "=", the character is replaced with a --sysroot value.
static Optional<std::string> findFile(StringRef Path1, const Twine &Path2) {
- SmallString<128> S;
+ SmallString<256> S;
if (Path1.startswith("="))
path::append(S, Config->Sysroot, Path1.substr(1), Path2);
else
path::append(S, Path1, Path2);
- if (fs::exists(S))
- return S.str().str();
+ SmallString<256> RealPath;
+ fs::real_path(S, RealPath);
+ if (fs::exists(RealPath))
+ return RealPath.str().str();
return None;
}
@@ -220,8 +222,19 @@ Optional<std::string> elf::searchLibrary(StringRef Name) {
for (StringRef Dir : Config->SearchPaths) {
if (!Config->Static)
- if (Optional<std::string> S = findFile(Dir, "lib" + Name + ".so"))
- return S;
+ if (Name.size() == 1) {
+ if (Optional<std::string> S = findFile(Dir, "lib" + Name + ".lib.so"))
+ return S;
+ if (Optional<std::string> S = findFile(Dir, "lib" + Name + ".so"))
+ return S;
+ } else {
+ if (Optional<std::string> S = findFile(Dir, Name + ".lib.so"))
+ return S;
+ if (Optional<std::string> S = findFile(Dir, "lib" + Name + ".so"))
+ return S;
+ }
+ if (Optional<std::string> S = findFile(Dir, Name + ".lib.a"))
+ return S;
if (Optional<std::string> S = findFile(Dir, "lib" + Name + ".a"))
return S;
}

@ -47,10 +47,10 @@ in depotPkgs // {
targets = [ "bootstrap" "core" "timer" "lib/ld" ];
patches = basePatches;
postInstall = ''
mv $out/core-hw-pc.o $coreObj
mv $out/bootstrap-hw-pc.o $bootstrapObj
mv $out/ld-hw.lib.so $out/ld.lib.so
mv $out/hw_timer_drv $out/timer_drv
mv $out/lib/ld-hw.lib.so $out/lib/ld.lib.so
mv $out/bin/hw_timer_drv $out/bin/timer_drv
install build/bin/core-hw-pc.o $coreObj
install build/bin/bootstrap-hw-pc.o $bootstrapObj
'';
meta.platforms = [ "x86_64-genode" ];
};
@ -63,10 +63,10 @@ in depotPkgs // {
targets = [ "bootstrap" "core" "timer" "lib/ld" ];
patches = basePatches;
postInstall = ''
mv $out/core-hw-virt_qemu.o $coreObj
mv $out/bootstrap-hw-virt_qemu.o $bootstrapObj
mv $out/ld-hw.lib.so $out/ld.lib.so
mv $out/hw_timer_drv $out/timer_drv
mv $out/lib/ld-hw.lib.so $out/lib/ld.lib.so
mv $out/bin/hw_timer_drv $out/bin/timer_drv
install build/bin/core-hw-virt_qemu.o $coreObj
install build/bin/bootstrap-hw-virt_qemu.o $bootstrapObj
'';
meta.platforms = [ "aarch64-genode" ];
};
@ -78,9 +78,8 @@ in depotPkgs // {
targets = [ "core" "timer" "lib/ld" ];
patches = basePatches;
postInstall = ''
mkdir -p $out/lib
mv $out/ld-linux.lib.so $out/lib/ld.lib.so
mv $out/linux_timer_drv $out/timer_drv
mv $out/lib/ld-linux.lib.so $out/lib/ld.lib.so
mv $out/bin/linux_timer_drv $out/bin/timer_drv
'';
HOST_INC_DIR = buildPackages.glibc.dev + "/include";
};
@ -92,9 +91,9 @@ in depotPkgs // {
targets = [ "core" "timer" "lib/ld" ];
patches = basePatches;
postInstall = ''
mv $out/core-nova.o $coreObj
mv $out/ld-nova.lib.so $out/ld.lib.so
mv $out/nova_timer_drv $out/timer_drv
mv $out/lib/ld-nova.lib.so $out/lib/ld.lib.so
mv $out/bin/nova_timer_drv $out/bin/timer_drv
install build/bin/core-nova.o $coreObj
'';
};

@ -1,208 +0,0 @@
commit b7d219220e10699dedb2c90e2d4010cbfab74a86
Author: Emery Hemingway <ehmry@posteo.net>
Date: Sun Aug 30 10:47:51 2020 +0200
Produce libraries with conventional names
diff --git a/repos/base/mk/dep_lib.mk b/repos/base/mk/dep_lib.mk
index 21fcb77e58..533aebffa3 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 0531c08d58..4eefc6822c 100644
--- a/repos/base/mk/generic.mk
+++ b/repos/base/mk/generic.mk
@@ -139,7 +139,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.
@@ -174,12 +174,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 c8ac049563..776aea82aa 100644
--- a/repos/base/mk/lib.mk
+++ b/repos/base/mk/lib.mk
@@ -95,7 +95,12 @@ endif
#
ifneq ($(SYMBOLS),)
ABI_SO := $(addsuffix .abi.so,$(LIB))
+ifeq ($(LIB),ld)
ABI_SONAME := $(addsuffix .lib.so,$(LIB))
+else
+ABI_SONAME := $(addsuffix .so,$(addprefix lib,$(patsubst lib%,%,$(LIB))))
+endif
+
$(LIB).symbols:
$(VERBOSE)ln -sf $(SYMBOLS) $@
@@ -124,14 +129,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
@@ -151,7 +162,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)
@@ -204,7 +215,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
diff --git a/repos/base/src/lib/ldso/include/file.h b/repos/base/src/lib/ldso/include/file.h
index 1c9ce53ca3..a8875a781e 100644
--- a/repos/base/src/lib/ldso/include/file.h
+++ b/repos/base/src/lib/ldso/include/file.h
@@ -132,10 +132,10 @@ struct Linker::Elf_file : File
* the end of the linker area to ensure that the newly loaded
* binary has enough room within the linker area.
*/
- bool const resident = (name == "libc.lib.so")
- || (name == "libm.lib.so")
- || (name == "posix.lib.so")
- || (strcmp(name.string(), "vfs", 3) == 0);
+ bool const resident = (name == "libc.so")
+ || (name == "libm.so")
+ || (name == "libposix.so")
+ || (strcmp(name.string(), "libvfs", 6) == 0);
reloc_base = resident ? Region_map::r()->alloc_region_at_end(size)
: Region_map::r()->alloc_region(size);
diff --git a/repos/libports/src/lib/libc/execve.cc b/repos/libports/src/lib/libc/execve.cc
index 73fd407db7..554d943763 100644
--- a/repos/libports/src/lib/libc/execve.cc
+++ b/repos/libports/src/lib/libc/execve.cc
@@ -325,10 +325,10 @@ void Libc::init_execve(Env &env, Genode::Allocator &alloc, void *user_stack_ptr,
_binary_name_ptr = &binary_name;
_fd_alloc_ptr = &fd_alloc;
- Dynamic_linker::keep(env, "libc.lib.so");
- Dynamic_linker::keep(env, "libm.lib.so");
- Dynamic_linker::keep(env, "posix.lib.so");
- Dynamic_linker::keep(env, "vfs.lib.so");
+ Dynamic_linker::keep(env, "libc.so");
+ Dynamic_linker::keep(env, "libm.so");
+ Dynamic_linker::keep(env, "libposix.so");
+ Dynamic_linker::keep(env, "libvfs.so");
}
diff --git a/repos/libports/src/lib/libc/kernel.cc b/repos/libports/src/lib/libc/kernel.cc
index b1bca7c80f..a4bebaeae1 100644
--- a/repos/libports/src/lib/libc/kernel.cc
+++ b/repos/libports/src/lib/libc/kernel.cc
@@ -418,10 +418,10 @@ void Libc::Kernel::_clone_state_from_parent()
* regular startup of the child.
*/
bool const blacklisted = (name == "ld.lib.so")
- || (name == "libc.lib.so")
- || (name == "libm.lib.so")
- || (name == "posix.lib.so")
- || (strcmp(name.string(), "vfs", 3) == 0);
+ || (name == "libc.so")
+ || (name == "libm.so")
+ || (name == "libposix.so")
+ || (strcmp(name.string(), "libvfs", 6) == 0);
if (!blacklisted)
copy_from_parent(range_attr(node));
}
diff --git a/repos/os/src/lib/vfs/file_system_factory.cc b/repos/os/src/lib/vfs/file_system_factory.cc
index 48069d3fb8..53e8678757 100644
--- a/repos/os/src/lib/vfs/file_system_factory.cc
+++ b/repos/os/src/lib/vfs/file_system_factory.cc
@@ -117,7 +117,7 @@ Vfs::Global_file_system_factory::_try_create(Vfs::Env &env,
Library_name Vfs::Global_file_system_factory::_library_name(Node_name const &node_name)
{
char lib_name [Library_name::capacity()];
- Genode::snprintf(lib_name, sizeof(lib_name), "vfs_%s.lib.so",
+ Genode::snprintf(lib_name, sizeof(lib_name), "libvfs_%s.so",
node_name.string());
return Library_name(lib_name);

@ -30,7 +30,7 @@ let
version = upstreamSources.lastModifiedDate;
src = upstreamSources;
nativeBuildInputs = [ expect gnumake tcl ];
patches = [ ./LIB.patch ./binary-labels.patch ];
patches = [ ./binary-labels.patch ];
configurePhase = ''
patchShebangs ./tool
substituteInPlace repos/base/etc/tools.conf \
@ -166,7 +166,10 @@ let
installPhase = ''
runHook preInstall
find build/bin -name '*.xsd' -delete
find build/bin -follow -type f -exec install -Dt $out '{}' \;
find build/bin -follow -type f -name '*.lib.so' \
-exec install -Dt "''${!outputLib}/lib" {} \; -delete
find build/bin -follow -type f -executable \
-exec install -Dt "''${!outputBin}/bin" {} \;
runHook postInstall
'';
@ -221,8 +224,10 @@ let
installPhase = ''
runHook preInstall
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"
find depot/genodelabs/bin/${arch}/${name} -name '*.lib.so' \
-exec install -Dt "''${!outputLib}/lib" {} \; -delete
find depot/genodelabs/bin/${arch}/${name} -executable \
-exec install -Dt "''${!outputBin}/bin" {} \;
runHook postInstall
'';
@ -251,7 +256,7 @@ let
++ lib.optional isx86_64 "x86_64";
genodeBase =
# A package containing the Genode C++ headers, a stub ld.lib.so and libvfs.lib.so
# A package containing the Genode C++ headers, a stub ld.lib.so and vfs.lib.so
buildUpstream {
name = "base";
targets = [ "LIB=vfs" ];

Loading…
Cancel
Save