Skip to content

Commit 4b2f8bd

Browse files
prepare for /usr/bin/gfortran.
in the Makefile, add fortran to the list of languages to configure. add configure-target-libquadmath and configure-target-libgfortran to the listof mknative targets to invoke. while here also remove some HAVE_GCC < 12 support. in mknative-gcc, remove ancient dead get_libg2c(), grab a couple more libgomp variables (will be used to replace some hard coded things and also adds the gomp/fortran portions), add new get functions for libquadmath and libgfortran, and also fetch the rest of the necessary variables.
1 parent 364b589 commit 4b2f8bd

2 files changed

Lines changed: 56 additions & 27 deletions

File tree

tools/gcc/Makefile

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $NetBSD: Makefile,v 1.118 2025/09/17 02:17:51 mrg Exp $
1+
# $NetBSD: Makefile,v 1.119 2026/01/17 23:43:46 mrg Exp $
22

33
.include <bsd.hostinit.mk>
44

@@ -14,18 +14,19 @@ MKNATIVE= ${.CURDIR}/mknative-${EXTERNAL_GCC_SUBDIR}
1414
CC_FOR_BUILD= ${HOST_CXX:Q}
1515
MKNATIVE?= ${.CURDIR}/mknative-gcc
1616

17-
# Force C++11 so builds succeed on hosts where this isn't the compiler
18-
# default, e.g., NetBSD 8.x with GCC 5.5.
19-
.if ${HAVE_GCC} > 10
17+
# GCC since 10.x (at least) needs C++11
2018
HOST_CXXFLAGS+= -std=c++11
21-
.endif
2219

2320
.if ${MACHINE_ARCH} == "x86_64" || ${MACHINE_ARCH} == "sparc64"
2421
MULTILIB_ARGS= --enable-multilib
2522
.else
2623
MULTILIB_ARGS= --disable-multilib
2724
.endif
2825

26+
.if ${HAVE_GCC} >= 14
27+
GCC_LANGUAGES+= fortran
28+
.endif
29+
2930
.if ${MKSOFTFLOAT} != "no" && ${MACHINE_CPU} != "m68k" \
3031
&& ${MACHINE_CPU} != "or1k" && ${MACHINE_CPU} != "sh3"
3132
SOFTFLOAT_ARGS= -with-float=soft
@@ -118,6 +119,12 @@ MKNATIVE_CONFIG_TARGET_LIBS+= \
118119
configure-target-libbacktrace \
119120
configure-target-libobjc
120121

122+
.if ${HAVE_GCC} >= 14
123+
MKNATIVE_CONFIG_TARGET_LIBS+= \
124+
configure-target-libquadmath \
125+
configure-target-libgfortran
126+
.endif
127+
121128
# XXX needs to build libstdc++ fully, which fails
122129
.if 0
123130
MKNATIVE_CONFIG_TARGET_LIBS+= \

tools/gcc/mknative-gcc

Lines changed: 44 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/sh
2-
# $NetBSD: mknative-gcc,v 1.122 2025/10/29 05:35:15 mrg Exp $
2+
# $NetBSD: mknative-gcc,v 1.123 2026/01/17 23:43:46 mrg Exp $
33
#
44
# Shell script for generating all the constants needed for a native
55
# platform build of gcc.
@@ -45,26 +45,6 @@ sanitise_includes () {
4545
-e "s,-I/usr/include/[^ ]*,,"
4646
}
4747

48-
##### lib/libg2c #####
49-
50-
get_libg2c () {
51-
mkdir -p $_OUTDIR/lib/libg2c3/arch/$_MACHINE_ARCH
52-
53-
write_c $_OUTDIRBASE/lib/libg2c3/arch/$_MACHINE_ARCH/config.h <$_TMPDIR/$_PLATFORM/libf2c/libU77/config.h
54-
write_c $_OUTDIRBASE/lib/libg2c3/arch/$_MACHINE_ARCH/g2c.h <$_TMPDIR/$_PLATFORM/libf2c/g2c.h
55-
56-
{
57-
getvars $_PLATFORM/libf2c/Makefile \
58-
F2CEXT
59-
getvars $_PLATFORM/libf2c/libF77/Makefile \
60-
ALL_CFLAGS OBJS
61-
getvars $_PLATFORM/libf2c/libI77/Makefile \
62-
ALL_CFLAGS OBJS | sed 's,=,+=,'
63-
getvars $_PLATFORM/libf2c/libU77/Makefile \
64-
ALL_CFLAGS OBJS | sed 's,=,+=,'
65-
} | write_mk $_OUTDIRBASE/lib/libg2c3/arch/$_MACHINE_ARCH/defs.mk
66-
}
67-
6848
##### lib/libgcc #####
6949

7050
get_libgcc () {
@@ -168,6 +148,8 @@ get_libgomp () {
168148

169149
getvars $_PLATFORM/libgomp/Makefile \
170150
libgomp_la_SOURCES \
151+
nodist_libsubinclude_HEADERS \
152+
nodist_finclude_HEADERS \
171153
| write_mk $_OUTDIRBASE/lib/$_subdir/defs.mk
172154

173155
write_c $_OUTDIRBASE/lib/$_subdir/arch/$_MACHINE_ARCH/config.h \
@@ -192,6 +174,43 @@ get_libbacktrace () {
192174
<$_TMPDIR/$_PLATFORM/$_subdir/backtrace-supported.h
193175
}
194176

177+
##### lib/libquadmath #####
178+
179+
get_libquadmath () {
180+
_subdir="$1"
181+
182+
mkdir -p $_OUTDIR/lib/$_subdir
183+
# libquadmath config.h appears to be netbsd-cpu agnostic
184+
write_c $_OUTDIRBASE/lib/$_subdir/config.h \
185+
<$_TMPDIR/$_PLATFORM/$_subdir/config.h
186+
187+
getvars $_PLATFORM/$_subdir/Makefile \
188+
libquadmath_la_SOURCES \
189+
| write_mk $_OUTDIRBASE/lib/$_subdir/defs.mk
190+
}
191+
192+
##### lib/libgfortran #####
193+
194+
get_libgfortran () {
195+
_subdir="$1"
196+
197+
mkdir -p $_OUTDIR/lib/$_subdir/arch/$_MACHINE_ARCH
198+
write_c $_OUTDIRBASE/lib/$_subdir/arch/$_MACHINE_ARCH/config.h \
199+
<$_TMPDIR/$_PLATFORM/$_subdir/config.h
200+
201+
getvars $_PLATFORM/$_subdir/Makefile \
202+
libgfortran_la_SOURCES \
203+
FPU_HOST_HEADER \
204+
nodist_finclude_HEADERS \
205+
gfor_c_HEADERS \
206+
i_matmul_c i_matmulavx128_c i_matmull_c \
207+
gfor_specific_src gfor_ieee_src gfor_ieee_helper_src \
208+
| write_mk $_OUTDIRBASE/lib/$_subdir/arch/$_MACHINE_ARCH/defs.mk
209+
210+
write_mk $_OUTDIRBASE/lib/$_subdir/libgfortran.spec \
211+
<$_TMPDIR/$_PLATFORM/libgfortran/libgfortran.spec
212+
}
213+
195214
##### lib/libobjc #####
196215

197216
get_libobjc () {
@@ -376,6 +395,7 @@ get_gcc () {
376395
getvars gcc/Makefile \
377396
ALL_CFLAGS ALL_CPPFLAGS C_AND_OBJC_OBJS C_OBJS CCCP_OBJS \
378397
GCC_OBJS GCOV_OBJS GCOV_DUMP_OBJS GXX_OBJS GTM_H PROTO_OBJS ${_extravars1} \
398+
ALL_HOST_FRONTEND_OBJS \
379399
INCLUDES md_file OBJC_OBJS OBJS out_file version \
380400
BUILD_PREFIX RTL_H RTL_BASE_H TREE_H ${_hconfig_h} BASIC_BLOCK_H GCC_H \
381401
D_TARGET_DEF \
@@ -392,7 +412,7 @@ get_gcc () {
392412
getvars gcc/Makefile \
393413
CXX_OBJS CXX_C_OBJS | sed 's/cp\///g'
394414
getvars gcc/Makefile \
395-
F77_OBJS | sed 's/f\///g'
415+
F95_OBJS GFORTRAN_D_OBJS | sed 's/fortran\///g'
396416
getvars libcpp/Makefile \
397417
libcpp_a_OBJS
398418
getvars gcc/Makefile \
@@ -510,6 +530,8 @@ gcc*)
510530
get_libdecnumber libdecnumber
511531
get_libgomp libgomp
512532
get_libbacktrace libbacktrace
533+
get_libquadmath libquadmath
534+
get_libgfortran libgfortran
513535
exit 0
514536
;;
515537

0 commit comments

Comments
 (0)