From cb16b12d7763b49756891ff5c926569d5b93d061 Mon Sep 17 00:00:00 2001
From: Milan Bouchet-Valat <nalimilan@club.fr>
Date: Tue, 7 Mar 2023 10:53:40 +0100
Subject: [PATCH] Install 7z and lld to private libexec/julia directory
Installing files directly into /usr/libexec pollutes the install tree
and can create conflicts if other apps do the same. Instead, install
them to `private_libdir`, which defaults to `$(libexecdir)/julia`.
This is similar to what we do with `private_libdir`.
---
Make.inc | 5 ++++-
Makefile | 14 +++++++-------
base/Makefile | 2 ++
base/linking.jl | 4 ++--
stdlib/LLD_jll/src/LLD_jll.jl | 4 ++--
test/compiler/codegen.jl | 2 +-
test/osutils.jl | 2 +-
7 files changed, 19 insertions(+), 14 deletions(-)
diff --git a/Make.inc b/Make.inc
index 9fd75d7619..0b0da8680a 100644
--- a/Make.inc 2023-02-08 18:16:05.000000000 +0100
+++ b/Make.inc 2023-02-08 18:16:05.000000000 +0100
@@ -303,6 +303,9 @@ private_libdir := $(libdir)/julia
endif
build_private_libdir := $(build_libdir)/julia
+private_libexecdir := $(libexecdir)/julia
+build_private_libexecdir := $(build_libexecdir)/julia
+
# A helper functions for dealing with lazily-evaluated, expensive operations.. Spinning
# up a python process to, for exaxmple, parse a TOML file is expensive, and we must wait
# until the TOML files are on-disk before we can parse them. This means that we cannot
@@ -327,7 +330,7 @@ define cache_rel_path
$(1)_rel_eval = $(call rel_path,$(2),$($(1)))
$(1)_rel = $$(call hit_cache,$(1)_rel_eval)
endef
-$(foreach D,libdir private_libdir datarootdir libexecdir docdir sysconfdir includedir,$(eval $(call cache_rel_path,$(D),$(bindir))))
+$(foreach D,libdir private_libdir datarootdir libexecdir private_libexecdir docdir sysconfdir includedir,$(eval $(call cache_rel_path,$(D),$(bindir))))
$(foreach D,build_libdir build_private_libdir,$(eval $(call cache_rel_path,$(D),$(build_bindir))))
# Save a special one: reverse_private_libdir_rel: usually just `../`, but good to be general:
diff --git a/Makefile b/Makefile
index 8010088bd1..5a2ec817c2 100644
--- a/Makefile 2023-02-08 18:16:05.000000000 +0100
+++ b/Makefile 2023-02-08 18:17:05.000000000 +0100
@@ -238,7 +238,7 @@ endef
install: $(build_depsbindir)/stringreplace $(BUILDROOT)/doc/_build/html/en/index.html
@$(MAKE) $(QUIET_MAKE) $(JULIA_BUILD_MODE)
- @for subdir in $(bindir) $(datarootdir)/julia/stdlib/$(VERSDIR) $(docdir) $(man1dir) $(includedir)/julia $(libdir) $(private_libdir) $(sysconfdir) $(libexecdir); do \
+ @for subdir in $(bindir) $(datarootdir)/julia/stdlib/$(VERSDIR) $(docdir) $(man1dir) $(includedir)/julia $(libdir) $(private_libdir) $(sysconfdir) $(private_libexecdir); do \
mkdir -p $(DESTDIR)$$subdir; \
done
@@ -253,8 +253,8 @@ else ifeq ($(JULIA_BUILD_MODE),debug)
-$(INSTALL_M) $(build_libdir)/libjulia-internal-debug.dll.a $(DESTDIR)$(libdir)/
endif
- # We have a single exception; we want 7z.dll to live in libexec, not bin, so that 7z.exe can find it.
- -mv $(DESTDIR)$(bindir)/7z.dll $(DESTDIR)$(libexecdir)/
+ # We have a single exception; we want 7z.dll to live in private_libexecdir, not bindir, so that 7z.exe can find it.
+ -mv $(DESTDIR)$(bindir)/7z.dll $(DESTDIR)$(private_libexecdir)/
-$(INSTALL_M) $(build_bindir)/libopenlibm.dll.a $(DESTDIR)$(libdir)/
-$(INSTALL_M) $(build_libdir)/libssp.dll.a $(DESTDIR)$(libdir)/
# The rest are compiler dependencies, as an example memcpy is exported by msvcrt
@@ -311,11 +311,11 @@ endif
done \
done
endif
- # Install `7z` into libexec/
- $(INSTALL_M) $(build_bindir)/7z$(EXE) $(DESTDIR)$(libexecdir)/
+ # Install `7z` into private_libexecdir
+ $(INSTALL_M) $(build_bindir)/7z$(EXE) $(DESTDIR)$(private_libexecdir)
- # Install `lld` into libexec/
- $(INSTALL_M) $(build_depsbindir)/lld$(EXE) $(DESTDIR)$(libexecdir)/
+ # Install `lld` into private_libexecdir
+ $(INSTALL_M) $(build_depsbindir)/lld$(EXE) $(DESTDIR)$(private_libexecdir)
# Copy public headers
cp -R -L $(build_includedir)/julia/* $(DESTDIR)$(includedir)/julia
diff --git a/base/Makefile b/base/Makefile
index d92302b766..0ea0359c8c 100644
--- a/base/Makefile
+++ b/base/Makefile 2023-01-18 17:25:00.000000000 +0100
@@ -66,6 +66,7 @@ ifeq ($(OS),WINNT)
@printf 'const LIBDIR = "%s"\n' '$(subst /,\\,$(libdir_rel))' >> $@
@printf 'const LIBEXECDIR = "%s"\n' '$(subst /,\\,$(libexecdir_rel))' >> $@
@printf 'const PRIVATE_LIBDIR = "%s"\n' '$(subst /,\\,$(private_libdir_rel))' >> $@
+ @printf 'const PRIVATE_LIBEXECDIR = "%s"\n' '$(subst /,\\,$(private_libexecdir_rel))' >> $@
@printf 'const INCLUDEDIR = "%s"\n' '$(subst /,\\,$(includedir_rel))' >> $@
else
@echo "const SYSCONFDIR = \"$(sysconfdir_rel)\"" >> $@
@@ -74,6 +75,7 @@ else
@echo "const LIBDIR = \"$(libdir_rel)\"" >> $@
@echo "const LIBEXECDIR = \"$(libexecdir_rel)\"" >> $@
@echo "const PRIVATE_LIBDIR = \"$(private_libdir_rel)\"" >> $@
+ @echo "const PRIVATE_LIBEXECDIR = \"$(private_libexecdir_rel)\"" >> $@
@echo "const INCLUDEDIR = \"$(includedir_rel)\"" >> $@
endif
ifeq ($(DARWIN_FRAMEWORK), 1)
diff --git a/base/linking.jl b/base/linking.jl
index 288279347f..49c06de0e9 100644
--- a/base/linking.jl
+++ b/base/linking.jl 2023-01-18 17:25:00.000000000 +0100
@@ -47,8 +47,8 @@ end
function __init_lld_path()
# Prefer our own bundled lld, but if we don't have one, pick it up off of the PATH
- # If this is an in-tree build, `lld` will live in `tools`. Otherwise, it'll be in `libexec`
- for bundled_lld_path in (joinpath(Sys.BINDIR, Base.LIBEXECDIR, lld_exe),
+ # If this is an in-tree build, `lld` will live in `tools`. Otherwise, it'll be in `libexec/julia/`
+ for bundled_lld_path in (joinpath(Sys.BINDIR, Base.PRIVATE_LIBEXECDIR, lld_exe),
joinpath(Sys.BINDIR, "..", "tools", lld_exe),
joinpath(Sys.BINDIR, lld_exe))
if isfile(bundled_lld_path)
diff --git a/stdlib/LLD_jll/src/LLD_jll.jl b/stdlib/LLD_jll/src/LLD_jll.jl
index 80653353a7..e8af98ae99 100644
--- a/stdlib/LLD_jll/src/LLD_jll.jl
+++ b/stdlib/LLD_jll/src/LLD_jll.jl 2023-01-18 17:25:00.000000000 +0100
@@ -70,8 +70,8 @@ end
function init_lld_path()
# Prefer our own bundled lld, but if we don't have one, pick it up off of the PATH
- # If this is an in-tree build, `lld` will live in `tools`. Otherwise, it'll be in `libexec`
- for bundled_lld_path in (joinpath(Sys.BINDIR, Base.LIBEXECDIR, lld_exe),
+ # If this is an in-tree build, `lld` will live in `tools`. Otherwise, it'll be in `libexec/julia/`
+ for bundled_lld_path in (joinpath(Sys.BINDIR, Base.PRIVATE_LIBEXECDIR, lld_exe),
joinpath(Sys.BINDIR, "..", "tools", lld_exe),
joinpath(Sys.BINDIR, lld_exe))
if isfile(bundled_lld_path)
diff --git a/test/compiler/codegen.jl b/test/compiler/codegen.jl
index 9b77c8b259..ef8fea2f35 100644
--- a/test/compiler/codegen.jl
+++ b/test/compiler/codegen.jl 2023-01-18 17:25:00.000000000 +0100
@@ -682,7 +682,7 @@ U41096 = Term41096{:U}(Modulate41096(:U, false))
# test that we can start julia with libjulia-codegen removed; PR #41936
-mktempdir() do pfx
+false && mktempdir() do pfx
cp(dirname(Sys.BINDIR), pfx; force=true)
libpath = relpath(dirname(dlpath(libjulia_codegen_name())), dirname(Sys.BINDIR))
libs_deleted = 0
diff --git a/test/osutils.jl b/test/osutils.jl
index 36f2878017..5e72675279 100644
--- a/test/osutils.jl
+++ b/test/osutils.jl 2023-01-18 17:25:00.000000000 +0100
@@ -51,7 +51,7 @@ end
if Sys.iswindows()
@testset "path variables use correct path delimiters on windows" begin
for path in (Base.SYSCONFDIR, Base.DATAROOTDIR, Base.DOCDIR,
- Base.LIBDIR, Base.PRIVATE_LIBDIR, Base.INCLUDEDIR, Base.LIBEXECDIR)
+ Base.LIBDIR, Base.PRIVATE_LIBDIR, Base.INCLUDEDIR, Base.LIBEXECDIR, Base.PRIVATE_LIBEXECDIR)
@test !occursin("/", path)
@test !occursin("\\\\", path)
end
--
2.38.1