Hi ports --
Since armv7 had moved to lld as the default linker, it means that
gcc-4.9.4 is effectively broken; there are known problems with linking
gcc with lld (an error complaining about GCC_NO_EXECUTABLES).
The attached diff allows gcc-4.9.4 to be linked with lld on armv7. It
comes very very close to linking on amd64 too--everything links except
for libgcj.so, with the error message "section sh_addralign is not a
power of 2"
Which seems to be addressed here:
https://reviews.llvm.org/D25324
But I am not smart enough to figure out exactly what lld is complaining
about. Other than that one (obviously problematic) issue, all the rest
of gcc-4.9.4 can link with lld. Because there is no gcj for arm, the
build succeeds.
I sent this diff to pascal@ about a week ago but didn't get a response.
Now that phessler@ has sent out an arm package build report with gcc
failing to build because of lld, I feel like now's the time to get this
out for comment.
Additionally and unrelated, this diff also includes a line to more
strongly default to -fPIC on armv7, as I have been burned by gcc-4.9.4
on armv7 not always defaulting to -fPIC.
I need this to enable FreeBASIC on armv7, which uses gcc-4.9.4 as its
backend compiler. Clang is a no-go for FreeBASIC, as it writes C code
that clang refuses to compile.
~Brian
Index: Makefile
===================================================================
RCS file: /cvs/ports/lang/gcc/4.9/Makefile,v
retrieving revision 1.55
diff -u -p -r1.55 Makefile
--- Makefile 23 Jul 2018 10:05:35 -0000 1.55
+++ Makefile 31 Jul 2018 06:35:45 -0000
@@ -4,7 +4,7 @@ ONLY_FOR_ARCHS = ${GCC49_ARCHS}
DPB_PROPERTIES = parallel
V = 4.9.4
-REVISION = 9
+REVISION = 10
FULL_VERSION = $V
FULL_PKGVERSION = $V
Index: patches/patch-gcc_config_arm_openbsd_h
===================================================================
RCS file: /cvs/ports/lang/gcc/4.9/patches/patch-gcc_config_arm_openbsd_h,v
retrieving revision 1.4
diff -u -p -r1.4 patch-gcc_config_arm_openbsd_h
--- patches/patch-gcc_config_arm_openbsd_h 18 Sep 2016 15:05:15 -0000
1.4
+++ patches/patch-gcc_config_arm_openbsd_h 31 Jul 2018 06:35:45 -0000
@@ -1,7 +1,8 @@
$OpenBSD: patch-gcc_config_arm_openbsd_h,v 1.4 2016/09/18 15:05:15 pascal Exp $
---- gcc/config/arm/openbsd.h.orig Wed Sep 14 15:03:10 2016
-+++ gcc/config/arm/openbsd.h Sat Sep 17 21:13:46 2016
-@@ -0,0 +1,243 @@
+Index: gcc/config/arm/openbsd.h
+--- gcc/config/arm/openbsd.h.orig
++++ gcc/config/arm/openbsd.h
+@@ -0,0 +1,244 @@
+/* Definitions of target machine for GNU compiler, OpenBSD/arm ELF version.
+ Copyright (C) 2002 Free Software Foundation, Inc.
+ Contributed by Wasabi Systems, Inc.
@@ -80,7 +81,8 @@ $OpenBSD: patch-gcc_config_arm_openbsd_h
+ %{!static:-Bdynamic} \
+ %{rdynamic:-export-dynamic} \
+ %{assert*} \
-+ %{!dynamic-linker:-dynamic-linker /usr/libexec/ld.so}"
++ %{!dynamic-linker:-dynamic-linker /usr/libexec/ld.so} \
++ -L/usr/lib"
+#endif
+
+#undef SUBTARGET_EXTRA_ASM_SPEC
Index: patches/patch-gcc_config_gcc
===================================================================
RCS file: /cvs/ports/lang/gcc/4.9/patches/patch-gcc_config_gcc,v
retrieving revision 1.9
diff -u -p -r1.9 patch-gcc_config_gcc
--- patches/patch-gcc_config_gcc 15 Sep 2016 10:22:10 -0000 1.9
+++ patches/patch-gcc_config_gcc 31 Jul 2018 06:35:45 -0000
@@ -1,6 +1,7 @@
$OpenBSD: patch-gcc_config_gcc,v 1.9 2016/09/15 10:22:10 pascal Exp $
---- gcc/config.gcc.orig Mon Mar 14 11:03:12 2016
-+++ gcc/config.gcc Wed Sep 14 17:07:21 2016
+Index: gcc/config.gcc
+--- gcc/config.gcc.orig
++++ gcc/config.gcc
@@ -771,6 +771,14 @@ case ${target} in
default_use_cxa_atexit=yes
;;
@@ -25,11 +26,12 @@ $OpenBSD: patch-gcc_config_gcc,v 1.9 201
tm_file="elfos.h alpha/alpha.h alpha/elf.h openbsd.h openbsd-stdint.h
alpha/openbsd.h openbsd-libpthread.h"
extra_options="${extra_options} openbsd.opt alpha/elf.opt"
# default x-alpha is only appropriate for dec-osf.
-@@ -1018,6 +1026,12 @@ arm*-*-netbsdelf*)
+@@ -1018,6 +1026,13 @@ arm*-*-netbsdelf*)
extra_options="${extra_options} netbsd.opt netbsd-elf.opt"
tmake_file="${tmake_file} arm/t-arm"
;;
+arm-*-openbsd*)
++ tm_defines="${tm_defines} PIE_DEFAULT=1"
+ tm_file="dbxelf.h elfos.h arm/elf.h arm/aout.h arm/openbsd1.h arm/arm.h
openbsd.h openbsd-libpthread.h arm/openbsd.h"
+ extra_options="${extra_options} openbsd.opt"
+ tmake_file="${tmake_file} arm/t-arm arm/t-bpabi"
@@ -38,7 +40,7 @@ $OpenBSD: patch-gcc_config_gcc,v 1.9 201
arm*-*-linux-*) # ARM GNU/Linux with ELF
tm_file="dbxelf.h elfos.h gnu-user.h linux.h linux-android.h
glibc-stdint.h arm/elf.h arm/linux-gas.h arm/linux-elf.h"
extra_options="${extra_options} linux-android.opt"
-@@ -1206,6 +1220,7 @@ hppa*-*-linux*)
+@@ -1206,6 +1221,7 @@ hppa*-*-linux*)
;;
hppa*-*-openbsd*)
target_cpu_default="MASK_PA_11"
@@ -46,7 +48,7 @@ $OpenBSD: patch-gcc_config_gcc,v 1.9 201
tm_file="${tm_file} dbxelf.h elfos.h openbsd.h openbsd-stdint.h
openbsd-libpthread.h \
pa/pa-openbsd.h pa/pa32-regs.h pa/pa32-openbsd.h"
extra_options="${extra_options} openbsd.opt"
-@@ -1380,6 +1395,7 @@ i[34567]86-*-openbsd2.*|i[34567]86-*openbsd3.[0123])
+@@ -1380,6 +1396,7 @@ i[34567]86-*-openbsd2.*|i[34567]86-*openbsd3.[0123])
use_collect2=yes
;;
i[34567]86-*-openbsd*)
@@ -54,7 +56,7 @@ $OpenBSD: patch-gcc_config_gcc,v 1.9 201
tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h"
tm_file="${tm_file} openbsd.h openbsd-stdint.h openbsd-libpthread.h
i386/openbsdelf.h"
extra_options="${extra_options} openbsd.opt"
-@@ -1387,6 +1403,7 @@ i[34567]86-*-openbsd*)
+@@ -1387,6 +1404,7 @@ i[34567]86-*-openbsd*)
gnu_ld=yes
;;
x86_64-*-openbsd*)
@@ -62,7 +64,7 @@ $OpenBSD: patch-gcc_config_gcc,v 1.9 201
tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h"
tm_file="${tm_file} openbsd.h openbsd-stdint.h openbsd-libpthread.h
i386/x86-64.h i386/openbsdelf.h"
extra_options="${extra_options} openbsd.opt"
-@@ -1946,6 +1963,18 @@ microblaze*-*-elf)
+@@ -1946,6 +1964,18 @@ microblaze*-*-elf)
cxx_target_objs="${cxx_target_objs} microblaze-c.o"
tmake_file="${tmake_file} microblaze/t-microblaze"
;;
@@ -81,7 +83,7 @@ $OpenBSD: patch-gcc_config_gcc,v 1.9 201
mips*-*-netbsd*) # NetBSD/mips, either endian.
target_cpu_default="MASK_ABICALLS"
tm_file="elfos.h ${tm_file} mips/elf.h netbsd.h netbsd-elf.h
mips/netbsd.h"
-@@ -2173,11 +2202,12 @@ picochip-*)
+@@ -2173,11 +2203,12 @@ picochip-*)
use_gcc_stdint=wrap
tmake_file="picochip/t-picochip t-pnt16-warn"
;;
@@ -99,7 +101,7 @@ $OpenBSD: patch-gcc_config_gcc,v 1.9 201
powerpc-*-darwin*)
extra_options="${extra_options} rs6000/darwin.opt"
case ${target} in
-@@ -2747,11 +2777,19 @@ sparc64-*-netbsd*)
+@@ -2747,11 +2778,19 @@ sparc64-*-netbsd*)
extra_options="${extra_options} sparc/long-double-switch.opt"
tmake_file="${tmake_file} sparc/t-sparc sparc/t-netbsd64"
;;
@@ -120,7 +122,7 @@ $OpenBSD: patch-gcc_config_gcc,v 1.9 201
gas=yes gnu_ld=yes
with_cpu=ultrasparc
tmake_file="${tmake_file} sparc/t-sparc"
-@@ -2938,6 +2976,12 @@ case ${target} in
+@@ -2938,6 +2977,12 @@ case ${target} in
else
arch=i386
fi
Index: patches/patch-gcc_config_i386_openbsdelf_h
===================================================================
RCS file: /cvs/ports/lang/gcc/4.9/patches/patch-gcc_config_i386_openbsdelf_h,v
retrieving revision 1.2
diff -u -p -r1.2 patch-gcc_config_i386_openbsdelf_h
--- patches/patch-gcc_config_i386_openbsdelf_h 14 Jul 2016 07:22:31 -0000
1.2
+++ patches/patch-gcc_config_i386_openbsdelf_h 31 Jul 2018 06:35:45 -0000
@@ -1,13 +1,16 @@
$OpenBSD: patch-gcc_config_i386_openbsdelf_h,v 1.2 2016/07/14 07:22:31 tobiasu
Exp $
---- gcc/config/i386/openbsdelf.h.orig Thu Jan 2 23:23:26 2014
-+++ gcc/config/i386/openbsdelf.h Fri Jul 8 17:18:50 2016
-@@ -97,14 +97,17 @@ along with GCC; see the file COPYING3. If not see
+Index: gcc/config/i386/openbsdelf.h
+--- gcc/config/i386/openbsdelf.h.orig
++++ gcc/config/i386/openbsdelf.h
+@@ -97,14 +97,18 @@ along with GCC; see the file COPYING3. If not see
%{shared:-shared} %{R*} \
%{static:-Bstatic} \
%{!static:-Bdynamic} \
+ %{rdynamic:-export-dynamic} \
%{assert*} \
- -dynamic-linker /usr/libexec/ld.so"
+- -dynamic-linker /usr/libexec/ld.so"
++ -dynamic-linker /usr/libexec/ld.so \
++ -L/usr/lib"
#undef STARTFILE_SPEC
-#define STARTFILE_SPEC "\