Skip to content

Commit

Permalink
sys-apps/proot: Fix build on LLVM toolchains
Browse files Browse the repository at this point in the history
proot's makefile doesn't support overriding ld/pkg-config command
invocations, so patch it. An upstream patch has been sent:
proot-me/proot#359

proot doesn't link with LLVM ld, so force to use GNU ld.
proot-me/proot#360
  • Loading branch information
nya3jp committed Jul 5, 2023
1 parent 59e06bd commit a508670
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 6 deletions.
16 changes: 14 additions & 2 deletions sys-apps/proot/files/proot-5.1.0-makefile.patch
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
--- a/src/GNUmakefile 2018-08-01 16:30:00.957743804 +0300
+++ b/src/GNUmakefile 2018-08-01 16:30:34.876741798 +0300
@@ -15,8 +15,8 @@
@@ -13,10 +13,11 @@
STRIP = $(CROSS_COMPILE)strip
OBJCOPY = $(CROSS_COMPILE)objcopy
OBJDUMP = $(CROSS_COMPILE)objdump
+LD_CMD = $(CROSS_COMPILE)ld

CPPFLAGS += -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -I. -I$(VPATH)
-CFLAGS += -Wall -Wextra -O2
Expand All @@ -11,7 +14,16 @@

CARE_LDFLAGS = -larchive

@@ -182,7 +182,7 @@
@@ -130,7 +131,7 @@
$(Q)cat $^ >> $@
$(Q)echo "#endif /* BUILD_H */" >> $@

-BUILD_ID_NONE := $(shell if ld --build-id=none --version >/dev/null 2>&1; then echo ',--build-id=none'; fi)
+BUILD_ID_NONE := $(shell if ${LD_CMD} --build-id=none --version >/dev/null 2>&1; then echo ',--build-id=none'; fi)

######################################################################
# Build rules
@@ -182,7 +183,7 @@
$(eval $(call define_from_arch.h,$1,LOADER_ADDRESS))

LOADER_CFLAGS$1 += -fPIC -ffreestanding $(LOADER_ARCH_CFLAGS$1)
Expand Down
30 changes: 26 additions & 4 deletions sys-apps/proot/files/proot-5.3.0-makefile.patch
Original file line number Diff line number Diff line change
@@ -1,11 +1,33 @@
--- a/src/GNUmakefile 2022-01-21 11:40:00.957743804 +0300
+++ b/src/GNUmakefile 2022-01-21 11:40:34.876741798 +0300
@@ -21,8 +21,8 @@
HAS_PYTHON_CONFIG := $(shell ${PYTHON}-config --ldflags ${PYTHON_EMBED} 2>/dev/null)
@@ -14,6 +14,8 @@
OBJCOPY = $(CROSS_COMPILE)objcopy
OBJDUMP = $(CROSS_COMPILE)objdump
PYTHON = python3
+LD_CMD = $(CROSS_COMPILE)ld
+PKG_CONFIG = $(CROSS_COMPILE)pkg-config

HAS_SWIG := $(shell swig -version 2>/dev/null)
PYTHON_MAJOR_VERSION = $(shell ${PYTHON} -c "import sys; print(sys.version_info.major)" 2>/dev/null)
@@ -22,9 +24,9 @@

CPPFLAGS += -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -I. -I$(VPATH)
-CFLAGS += -g -Wall -Wextra -O2
-CFLAGS += $(shell pkg-config --cflags talloc libarchive)
+CFLAGS += -Wall -Wextra
CFLAGS += $(shell pkg-config --cflags talloc libarchive)
+CFLAGS += $(shell ${PKG_CONFIG} --cflags talloc libarchive)
LDFLAGS += -Wl,-z,noexecstack
LDFLAGS += $(shell pkg-config --libs talloc libarchive)
-LDFLAGS += $(shell pkg-config --libs talloc libarchive)
+LDFLAGS += $(shell ${PKG_CONFIG} --libs talloc libarchive)

CARE_LDFLAGS = -larchive

@@ -159,7 +161,7 @@
$(Q)cat $^ >> $@
$(Q)echo "#endif /* BUILD_H */" >> $@

-BUILD_ID_NONE := $(shell if ld --build-id=none --version >/dev/null 2>&1; then echo ',--build-id=none'; fi)
+BUILD_ID_NONE := $(shell if ${LD_CMD} --build-id=none --version >/dev/null 2>&1; then echo ',--build-id=none'; fi)

######################################################################
# Build rules
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ src_compile() {
# build the proot and care targets
emake -C src V=1 \
CC="$(tc-getCC)" \
LD="$(tc-getCC) -fuse-ld=bfd" \
LD_CMD="$(tc-getLD)" \
OBJCOPY="$(tc-getOBJCOPY)" \
OBJDUMP="$(tc-getOBJDUMP)" \
STRIP="$(tc-getSTRIP)" \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ src_compile() {
# build the proot and care targets
emake -C src V=1 \
CC="$(tc-getCC)" \
LD="$(tc-getCC) -fuse-ld=bfd" \
LD_CMD="$(tc-getLD)" \
PKG_CONFIG="$(tc-getPKG_CONFIG)" \
OBJCOPY="$(tc-getOBJCOPY)" \
OBJDUMP="$(tc-getOBJDUMP)" \
STRIP="$(tc-getSTRIP)" \
Expand Down

0 comments on commit a508670

Please sign in to comment.