Edit LINK_SPEC, fix static linking with ports-gcc

egcc -static was broken on most arches; the static binary wrongly
requested ld.so(1), but /usr/lib/rcrt0.o wants to do the relocation
without ld.so(1).  The fix is to drop ld.so,

    %{!static:-dynamic-linker /usr/libexec/ld.so}

Remove "%{!dynamic-linker:...}" because gcc -dynamic-linker is not an
option.  Correct "%{!r*:...}" to "%{!r:...}" because gcc -r doesn't
take an option argument.  Use "%{!nostdlib:-L/usr/lib}" on lld
arches, like base-gcc.

Edit the powerpc LINK_SPEC in rs6000/openbsd.h to be like the others.
Add "%{!nostdlib:-L/usr/lib}" so I can try lld on powerpc.  For now,
don't edit the powerpc64 LINK_SPEC.

ok pascal@ (maintainer)
This commit is contained in:
gkoehler 2021-01-24 04:41:50 +00:00
parent 076d29f16b
commit bea053a8c6
9 changed files with 37 additions and 33 deletions

View File

@ -1,4 +1,4 @@
# $OpenBSD: Makefile,v 1.38 2021/01/23 16:52:12 kettenis Exp $
# $OpenBSD: Makefile,v 1.39 2021/01/24 04:41:50 gkoehler Exp $
ONLY_FOR_ARCHS = aarch64 alpha amd64 arm hppa i386 mips64 mips64el \
powerpc powerpc64 sparc64
@ -18,7 +18,7 @@ DPB_PROPERTIES = parallel
V = 8.4.0
FULL_VERSION = $V
FULL_PKGVERSION = $V
REVISION = 3
REVISION = 4
ADASTRAP-amd64 = adastrap-amd64-8.3.0-2.tar.xz
ADASTRAP-arm = adastrap-arm-4.9.4-0.tar.xz

View File

@ -1,4 +1,4 @@
$OpenBSD: patch-gcc_config_aarch64_openbsd_h,v 1.2 2019/05/20 14:59:05 pascal Exp $
$OpenBSD: patch-gcc_config_aarch64_openbsd_h,v 1.3 2021/01/24 04:41:50 gkoehler Exp $
Index: gcc/config/aarch64/openbsd.h
--- gcc/config/aarch64/openbsd.h.orig
@ -51,14 +51,14 @@ Index: gcc/config/aarch64/openbsd.h
+#define SUBTARGET_CPP_SPEC OBSD_CPP_SPEC
+
+#define LINK_SPEC \
+ "%{!shared:%{!nostdlib:%{!r*:%{!e*:-e __start}}}} \
+ "%{!shared:%{!nostdlib:%{!r:%{!e*:-e __start}}}} \
+ %{shared:-shared} %{R*} \
+ %{static:-Bstatic} \
+ %{!static:-Bdynamic} \
+ %{rdynamic:-export-dynamic} \
+ %{assert*} \
+ %{!shared:%{!dynamic-linker:-dynamic-linker /usr/libexec/ld.so}} \
+ -L/usr/lib"
+ %{!static:-dynamic-linker /usr/libexec/ld.so} \
+ %{!nostdlib:-L/usr/lib}"
+
+#define OPENBSD_ENTRY_POINT "__start"
+

View File

@ -1,4 +1,4 @@
$OpenBSD: patch-gcc_config_alpha_openbsd_h,v 1.2 2019/05/20 14:59:05 pascal Exp $
$OpenBSD: patch-gcc_config_alpha_openbsd_h,v 1.3 2021/01/24 04:41:50 gkoehler Exp $
Index: gcc/config/alpha/openbsd.h
--- gcc/config/alpha/openbsd.h.orig
+++ gcc/config/alpha/openbsd.h
@ -10,14 +10,14 @@ Index: gcc/config/alpha/openbsd.h
+#define TARGET_DEFAULT \
+ (MASK_FPREGS | MASK_IEEE | MASK_IEEE_CONFORMANT)
+
+ #define LINK_SPEC \
+ "%{!shared:%{!nostdlib:%{!r*:%{!e*:-e __start}}}} \
+#define LINK_SPEC \
+ "%{!shared:%{!nostdlib:%{!r:%{!e*:-e __start}}}} \
+ %{shared:-shared} %{R*} \
+ %{static:-Bstatic} \
+ %{!static:-Bdynamic} \
+ %{rdynamic:-export-dynamic} \
+ %{assert*} \
+ %{!shared:%{!dynamic-linker:-dynamic-linker /usr/libexec/ld.so}}"
+ %{!static:-dynamic-linker /usr/libexec/ld.so}"
+
+/* As an elf system, we need crtbegin/crtend stuff. */
+#undef STARTFILE_SPEC

View File

@ -1,4 +1,4 @@
$OpenBSD: patch-gcc_config_arm_openbsd_h,v 1.2 2019/05/20 14:59:05 pascal Exp $
$OpenBSD: patch-gcc_config_arm_openbsd_h,v 1.3 2021/01/24 04:41:50 gkoehler Exp $
Index: gcc/config/arm/openbsd.h
--- gcc/config/arm/openbsd.h.orig
+++ gcc/config/arm/openbsd.h
@ -73,16 +73,16 @@ Index: gcc/config/arm/openbsd.h
+#undef OBSD_LINK_SPEC
+#ifdef OBSD_NO_DYNAMIC_LIBRARIES
+#define OBSD_LINK_SPEC \
+ "%{!nostdlib:%{!r*:%{!e*:-e __start}}} %{assert*}"
+ "%{!nostdlib:%{!r:%{!e*:-e __start}}} %{assert*}"
+#else
+#define OBSD_LINK_SPEC \
+ "%{!shared:%{!nostdlib:%{!r*:%{!e*:-e __start}}}} \
+ "%{!shared:%{!nostdlib:%{!r:%{!e*:-e __start}}}} \
+ %{shared:-shared} %{R*} \
+ %{static:-Bstatic} \
+ %{!static:-Bdynamic} \
+ %{rdynamic:-export-dynamic} \
+ %{assert*} \
+ %{!shared:%{!dynamic-linker:-dynamic-linker /usr/libexec/ld.so}} \
+ %{!static:-dynamic-linker /usr/libexec/ld.so} \
+ %{!nostdlib:-L/usr/lib}"
+#endif
+

View File

@ -1,4 +1,4 @@
$OpenBSD: patch-gcc_config_i386_openbsdelf_h,v 1.3 2020/08/08 16:48:48 sthen Exp $
$OpenBSD: patch-gcc_config_i386_openbsdelf_h,v 1.4 2021/01/24 04:41:50 gkoehler Exp $
Index: gcc/config/i386/openbsdelf.h
--- gcc/config/i386/openbsdelf.h.orig
@ -10,8 +10,8 @@ Index: gcc/config/i386/openbsdelf.h
+ %{rdynamic:-export-dynamic} \
%{assert*} \
- -dynamic-linker /usr/libexec/ld.so"
+ %{!shared:%{!-dynamic-linker:-dynamic-linker /usr/libexec/ld.so}} \
+ -L/usr/lib"
+ %{!static:-dynamic-linker /usr/libexec/ld.so} \
+ %{!nostdlib:-L/usr/lib}"
#undef STARTFILE_SPEC
-#define STARTFILE_SPEC "\

View File

@ -1,4 +1,4 @@
$OpenBSD: patch-gcc_config_mips_openbsd_h,v 1.2 2019/05/20 14:59:05 pascal Exp $
$OpenBSD: patch-gcc_config_mips_openbsd_h,v 1.3 2021/01/24 04:41:50 gkoehler Exp $
Index: gcc/config/mips/openbsd.h
--- gcc/config/mips/openbsd.h.orig
+++ gcc/config/mips/openbsd.h
@ -142,7 +142,7 @@ Index: gcc/config/mips/openbsd.h
+ %{!static:-Bdynamic} \
+ %{rdynamic:-export-dynamic} \
+ %{assert*} \
+ %{!shared:%{!dynamic-linker:-dynamic-linker /usr/libexec/ld.so}}"
+ %{!static:-dynamic-linker /usr/libexec/ld.so}"
+
+/* As an elf system, we need crtbegin/crtend stuff. */
+#undef STARTFILE_SPEC

View File

@ -1,4 +1,4 @@
$OpenBSD: patch-gcc_config_pa_pa-openbsd_h,v 1.2 2019/05/20 14:59:05 pascal Exp $
$OpenBSD: patch-gcc_config_pa_pa-openbsd_h,v 1.3 2021/01/24 04:41:51 gkoehler Exp $
Index: gcc/config/pa/pa-openbsd.h
--- gcc/config/pa/pa-openbsd.h.orig
+++ gcc/config/pa/pa-openbsd.h
@ -9,7 +9,7 @@ Index: gcc/config/pa/pa-openbsd.h
+ %{rdynamic:-export-dynamic} \
%{assert*} \
- -dynamic-linker /usr/libexec/ld.so"
+ %{!shared:%{!dynamic-linker:-dynamic-linker /usr/libexec/ld.so}}"
+ %{!static:-dynamic-linker /usr/libexec/ld.so}"
#undef STARTFILE_SPEC
#define STARTFILE_SPEC "\

View File

@ -1,7 +1,8 @@
$OpenBSD: patch-gcc_config_rs6000_openbsd_h,v 1.1.1.1 2019/01/04 15:50:39 pascal Exp $
--- gcc/config/rs6000/openbsd.h.orig Fri Nov 15 12:47:25 2013
+++ gcc/config/rs6000/openbsd.h Fri Nov 15 12:49:07 2013
@@ -0,0 +1,129 @@
$OpenBSD: patch-gcc_config_rs6000_openbsd_h,v 1.2 2021/01/24 04:41:51 gkoehler Exp $
Index: gcc/config/rs6000/openbsd.h
--- gcc/config/rs6000/openbsd.h.orig
+++ gcc/config/rs6000/openbsd.h
@@ -0,0 +1,132 @@
+/* Configuration file for an rs6000 OpenBSD target.
+ Copyright (C) 1999 Free Software Foundation, Inc.
+
@ -63,12 +64,15 @@ $OpenBSD: patch-gcc_config_rs6000_openbsd_h,v 1.1.1.1 2019/01/04 15:50:39 pascal
+#define CPP_OS_DEFAULT_SPEC "%(cpp_os_openbsd)"
+
+#undef LINK_SPEC
+#define LINK_SPEC "%{shared:-shared} \
+ %{!shared: \
+ %{!static: \
+ %{rdynamic:-export-dynamic} \
+ %{!dynamic-linker:-dynamic-linker /usr/libexec/ld.so}} \
+ %{static:-static}}"
+#define LINK_SPEC \
+ "%{!shared:%{!nostdlib:%{!r:%{!e*:-e __start}}}} \
+ %{shared:-shared} %{R*} \
+ %{static:-Bstatic} \
+ %{!static:-Bdynamic} \
+ %{rdynamic:-export-dynamic} \
+ %{assert*} \
+ %{!static:-dynamic-linker /usr/libexec/ld.so} \
+ %{!nostdlib:-L/usr/lib}"
+
+#undef LIB_DEFAULT_SPEC
+#define LIB_DEFAULT_SPEC "%(lib_openbsd)"

View File

@ -1,4 +1,4 @@
$OpenBSD: patch-gcc_config_sparc_openbsd64_h,v 1.2 2019/05/20 14:59:05 pascal Exp $
$OpenBSD: patch-gcc_config_sparc_openbsd64_h,v 1.3 2021/01/24 04:41:51 gkoehler Exp $
Index: gcc/config/sparc/openbsd64.h
--- gcc/config/sparc/openbsd64.h.orig
+++ gcc/config/sparc/openbsd64.h
@ -68,7 +68,7 @@ Index: gcc/config/sparc/openbsd64.h
+ %{rdynamic:-export-dynamic} \
%{assert*} \
- -dynamic-linker /usr/libexec/ld.so"
+ %{!shared:%{!dynamic-linker:-dynamic-linker /usr/libexec/ld.so}}"
+ %{!static:-dynamic-linker /usr/libexec/ld.so}"
/* As an elf system, we need crtbegin/crtend stuff. */
#undef STARTFILE_SPEC