cc80,cc120: Adjust -Wno-narrowing for GCC >= 8.0
Add the necessary check for cc80 libraries so that GCC 12 succeeds in
building GCC 8.
Meanwhile, improve the GCC check to check for any GCC version >= 8.0.
gcc120: Skip installing the headers for plugin development
The list of headers to install and the b-header-vars file are hard to
generate from vendor makefiles and require manual creation from a staged
GCC installation.
Given that these files are only needed for developing GCC plugins
instead of running them, so just skip installing them in the base
system.
One more thing, the 'gengtype' tool should be installed (into
/usr/libexec/gcc120/plugin/) together with these headers for plugin
development.
gcc120: Rework the makefiles to fix issues and ease future upgrades
* Remove many obsolete comments copied from gcc80's makefiles.
* Remove the unneeded 'Makefile.intcxx_lib' because all the C++ files
have been renamed to use the proper .cc suffix so we can simply use
the <bsd.hostlib.mk> makefile.
* Rework libgcc's makefiles. Rewrite the libgcc/Makefile.src to
follow the processes in GCC's makefile as much as possible. Now the
libgcc is built with the same source list as in the GCC's makefile.
* Fix and rework libstdcxx's makefiles.
- Refactor headers/Makefile.headers to reduce the difference with
GCC's makefile.
- Add libconv_2017 and libconv_2020.
- Fix headers preparation and enable '-nostdinc++' for building the
component and product libraries. As a result, use FILESGROUPS
[21 lines not shown]
gcc120: Add makefiles based on gcc80
Based on the makefiles for gcc 8.3, by way of 9.5, 10.5, and 11.5
GCC 12.5 has added:
* a new library "libcody"
* a new place for compiler-related tools "c++tools"
* the static analyzer "gcc/analyzer"
Also, all (C++) '.c' files in gcc/ have been renamed to '.cc'.
contrib/gcc-12: Patch options to use DWARF v4 by default
Because our GDB in base is 7.6 and is too old to read the DWARF v5 that
is used by GCC 12.5 by default. In addition, there is no longer a
configure option to override the default DWARF version. Therefore, we
decided to patch the GCC source code.
We could tweak the world/kernel makefiles to add the
'-gdwarf-4 -gstrict-dwarf' options, but that couldn't solve the issue
that a user cannot use the base GDB to debug one's own binary built
outside the world/kernel.
Discussed-with: swildner
contrib/gcc-12: Apply local changes from GCC-8
bd23261bc0 libstdc++: Fix unsigned wraparound in codecvt::do_length [PR105857]
fca8e87b2e gcc: Define ElfW() if it is not defined.
2007c584a7 gcc8: Fix the fix.
9cf0c62db7 gccs had ElfW() already. Comment out for now.
2ecd6c6623 gcc: Allow our C++ headers to survive -Wsystem-headers (2).
894c19b2d8 gcc: Allow our C++ headers to survive -Wsystem-headers.
a69def156b gcc80: Handle TZ specific "%+" format in strftime.
fcad8200ea gcc80: Remove throw() from protos in libstdc++ headers.
3dcb3c95ea gcc80: Add alternative variant of pthread presence checking.
632577dbc0 gcc80: Adjust search paths for base compiler layout.
ed36d35d08 gcc80: Adjust default dynamic linker search location.
Import GCC 12.5.0 Release (2025-07-11)
Source downloaded from:
https://ftp.gnu.org/gnu/gcc/gcc-12.5.0/gcc-12.5.0.tar.xz
aly: All the unused files have been trimmed by checking the 'atime'
(access time):
1. Create a UFS filesystem using vn(4) and mount it at contrib/gcc-12;
2. Copy the full source over;
3. Touch all files: find . | xargs touch
4. Create a timestamp mark: touch TMARK
5. Manually touch the files to keep:
$ touch README COPYING* LAST_UPDATED gcc/BASE-VER
6. Build world
7. Delete unused files:
$ find . -type f '!' -anewer TMARK -delete
$ find . -empty -delete
gcc47/libsupc++: Fix config.h for cp-demangle.c
Similar to the previous fix to gcc80/libstdcxx/libconv_supc, apply the
same config.h fix to gcc47/libsupc++.
gcc80/libstdcxx: Fix config.h for libconv_supc/cp-demangle.c
cp-demangle.c is provided by libiberty, so it must be built with
libiberty's 'config.h'. Introduce the 'GCC_NO_INC' make variable to
avoid including any search paths so we can specify the correct search
path for cp-demangle.c. Meanwhile, add the rule to copy over the
libiberty config.h.
In addition, apply GCC_NO_INC=yes to other libstdcxx components as it
turned out these search paths are unneeded.
pc64: Add '-mno-fp-ret-in-387' compiler option
This option prevents returning floating-point values in x87 registers.
I don't think our kernel has such issues, but just be safe.
gcc47,gcc80: Define LINK_SSP_SPEC to link with libssp_nonshared.a
libssp_nonshared.a provides '__stack_chk_fail_local()' as a hidden
symbol to avoids PLT overhead on 32-bit x86 by deferring PIC register
setup to the cold failure path. Although our libc.a (static) also
provides the '__stack_chk_fail_local()', it cannot be used when the
program is dynamically linked.
Note that on x86-64, GCC calls '__stack_chk_fail()' directly because
RIP-relative addressing makes PLT efficient, but we link
libssp_nonshared.a for consistency with other systems as well as for
future-proof.
One more thing, the 'TARGET_LIBC_PROVIDES_SSP' macro is undefined in GCC
4.7's 'auto-host.h' but defined to be 1 in GCC 8.0's. However, this
difference is ignored when 'LINK_SSP_SPEC' is explicitly defined.
gnu/lib/csu: Remove unused MFILE=${.ALLSRC} from 'tm.h' target
All the ${MFILE} variables used in gnu/usr.bin/cc* refer to man pages,
so this MFILE=${.ALLSRC} is never used.
gcc47: Minor cleanups to makefiles
- Remove unused LIBSUPCPP and GTFILES_SRCDIR.
- Include <bsd.subdir.mk> instead of <bsd.obj.mk> for cc_tools/Makefile
to make more sense.