Commit Graph

279 Commits

Author SHA1 Message Date
Quentin Boswank
fd04f43617 Add option to re-enable ˋlibstdc++ˋ on avr targets.
Due to the small flash space on AVR devices the library containing the
standard types in C++ (ˋlibstdc++ˋ) does not get built normally when
enabling the C++ language support.

This option is an easy way to go back to the PC-way where ˋlibstdc++ˋ is
built.

Signed-off-by: Quentin Boswank <qubos@outlook.de>
2023-08-14 16:12:12 +12:00
Kirill K. Smirnov
ada71ff2a0 Properly build multilib bare-metal RISC-V
To build multilib RISC-V toolchain one should use --with-multilib-generator
option instead of --with-multilib-list.

Add corresponding example configuration file.

Signed-off-by: Kirill K. Smirnov <kirill.k.smirnov@gmail.com>
2023-07-14 14:01:08 +12:00
Keith Packard
06faf2002e picolibc: Don't disable libstdc++ wchar_t for 1.8.1 or newer
Picolibc 1.8.1 has wchar_t stdio support, so libstdc++ can include
it.

Signed-off-by: Keith Packard <keithp@keithp.com>
2023-04-19 15:13:55 +12:00
Keith Packard
9e13e83068 gcc: Add --disable-wchar_t and --enable-stdio=pure for picolibc
Picolibc needs two additional gcc build options so that libstdc++
works correctly. When building picolibc as a companion library, those
are added in do_cc_libstdcxx_picolibc, but when built with picolibc as
the main C libary, those need to be added in the main GCC build.

Signed-off-by: Keith Packard <keithp@keithp.com>
2023-03-08 16:54:12 +13:00
Quentin Boswank
4cba299460 Add zstd to the companion libs
Add zstd to the companion libs witch allows to use lto zstd compression
in a canadian or cross-native enviroment

Signed-off-by: QBos07 <62326551+QBos07@users.noreply.github.com>
Signed-off-by: Quentin Boswank <62326551+QBos07@users.noreply.github.com>
2023-02-08 17:13:42 +13:00
Marc Poulhiès
cdae8d0559 Enable support for building libgccjit
libgccjit is still under development and, despite its name, may also be used for
ahead-of-time compilation.

Documentation can be found on the gcc website:
https://gcc.gnu.org/onlinedocs/jit/internals/index.html
https://gcc.gnu.org/wiki/JIT

With this change it's possible to enable the building of the libgccjit. It's
enabled as a language (with --enable-languages=jit) even if not a language
frontend at all.

The main changes are related to the requirement of having everything host side
built as Position Independent Code (PIC) with --enable-host-shared. GCC has the
needed logic for building its dependencies (mpc, gmp, mpfr, ...) correctly when
built "in-tree", which is not the case with crosstool-ng (see
https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=05048fc29f0)

Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
2022-12-18 21:20:50 +13:00
Joakim Nohlgård
16f6112327 scripts/gcc: Add extra include dir with -idirafter
Fixes Canadian cross builds failing with missing include file 'stdio.h'
when building libstdc++ for a companion libc with system libc set to
LIBC_NONE.

Signed-off-by: Joakim Nohlgård <joakim@nohlgard.se>
2022-12-11 19:52:26 +13:00
Joakim Nohlgård
e04351d666 scripts/gcc: align test conditionals with rest of repo
Most scripts in crosstool-ng use [ -z "${string}" ] to check for empty
variables.

Deleted one duplicate declaration of the local exec_prefix

Signed-off-by: Joakim Nohlgård <joakim@nohlgard.se>
2022-12-11 19:52:26 +13:00
Chris Packham
1b47500875 cc/gcc: Use canon_prefix when dealing with moved libraries
${CT_PREFIX_DIR} may contain relative paths (e.g.
"${CT_TOP_DIR}/../x-tools/${CT_TARGET}"). Code added in commit d83a0036
("Add symlinks from the libraries' original location to the new one.")
didn't cope well with this. As we're already calculating
${cannon_prefix} make use of it when adding the symlinks. This avoids
any issues with ${CT_PREFIX_DIR}.

Fixes #1807
Signed-off-by: Chris Packham <judge.packham@gmail.com>
2022-09-26 10:46:28 +13:00
Like Ma
a9f77be56f Add CC_GCC_ENABLE_DEFAULT_PIE
Enable Position Independent Executable as default

Pass --enable-default-pie to crossgcc's configure

Signed-off-by: Like Ma <likemartinma@gmail.com>
2022-08-19 22:02:11 +12:00
Norbert Lange
ee635cdf9a Fixes for libstdcxx-verbose option tristate
Make it proper "tristate" by not specifying the
option.

The config GCC_4_8_or_later was removed with
cc6b7fad46, so dont use it.
2022-07-11 19:50:29 +12:00
Chris Packham
f5e0d33ab4 Allow libsanitizer on architectures that support it
libsanitizer is only supported on selected architectures. Add
ARCH_SUPPORTS_LIBSANITIZER and have architectures select this option
based on the list of supported configurations from GCC's
libsanitizer/configure.tgt. Support for mips64 was added in GCC12 so
this is an additional condition for the mips architecture.

Fixes #1733

Signed-off-by: Chris Packham <judge.packham@gmail.com>
2022-07-11 19:49:23 +12:00
Justin Chen
c97a785485 Switch CT_CC_{CORE_}SYSROOT_ARG to arrays
CT_CC_{CORE_}SYSROOT_ARG is being used both as an array and string. Switch everything
to be used as an array for consistency.

Signed-off-by: Justin Chen <justinpopo6@gmail.com>
2022-07-01 16:33:37 +12:00
Marc Poulhiès
618affc789 Enable D language support
Enable D support as an experimental feature.
GDC becomes a build dependency when enabled.

Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
2022-06-14 20:54:54 +12:00
Guillermo E. Martinez
3d706748b4 gcc: Fix compilation error in core C gcc compiler older than v5
When core gcc older than v5 is compiled it shows the error message:

Build failed in step 'Installing core C gcc compiler'
      called in step '(top-level)'

Error happened in: CT_DoExecLog[scripts/functions@376]
      called from: do_gcc_core_backend[scripts/build/cc/gcc.sh@627]
      called from: do_cc_core[scripts/build/cc/gcc.sh@210]
      called from: main[scripts/crosstool-NG.sh@697]

configure: error: in
`.../build/build-cc-gcc-core/fixincludes':
configure: error: C compiler cannot create executables

This patch disable `all-build-libcpp' target when core gcc
older than v5 is configured.

Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
2022-06-01 14:50:43 +12:00
Chris Packham
db6f703f52 gcc: Add 12.1
Add GCC 12.1 https://gcc.gnu.org/gcc-12/

The following patches from GCC 11.3.0 are no longer needed:
- 0005-arc-Update-ZOL-pattern.patch
- 0006-arc-Update-u-maddhisi4-patterns.patch
- 0007-arc-Fix-maddhisi-patterns.patch
- 0008-Darwin-aarch64-Initial-support-for-the-self-host-dri.patch
- 0009-libstdc-Check-for-TLS-support-on-mingw-cross-compile.patch

One new patch is needed to avoid issues building sh-unknown-elf:
- 0006-sh-Avoid-mb-m1-multilib-combination.patch

It is also necessary to build all-build-libcpp. This target exists as
far back as GCC 6 so has been done unconditionally.

Signed-off-by: Chris Packham <judge.packham@gmail.com>
2022-05-19 14:24:46 +12:00
Joel Holdsworth
fd694dde63 cc/gcc: Create liblto_plugin symbolic link with correct extension
Previously, cc/gcc.sh assumed that liblto_plugin would always be
installed with the ".so" file extension. However, this assumption is
incorrect when the host machine is Windows (".dll") or MacOS (".dylib").

This patch corrects this issue by probing the file extension in similar
fashion to the way adjacent code determines the file extension of
executable binaries.

Signed-off-by: Joel Holdsworth <jholdsworth@nvidia.com>
2022-05-11 20:25:42 +12:00
Joel Holdsworth
d10a4318ac cc/gcc: Ensure value of ext is always set
The "ext" variable is set with the file extension of executable binaries
for a given platform. To improve tidiness, this patch ensures the
variable is always set even when there is no file path.

Signed-off-by: Joel Holdsworth <jholdsworth@nvidia.com>
2022-05-11 20:25:42 +12:00
Joel Holdsworth
d824983203 cc/gcc: Declare "file" and "ext" variables local
In do_gcc_core_backend and do_gcc_backend, variables "file" and "ext"
are used to store intermediate values. Previously, these were not
declared local. This patch corrects this issue.

Signed-off-by: Joel Holdsworth <jholdsworth@nvidia.com>
2022-05-11 20:25:42 +12:00
Joel Holdsworth
da1ffd0412 cc/gcc: Remove -lstdc++ and -lm from gcc LDFLAGS
In Bryan Hundven's patch 1ad439907 from 2010, the author added -lstdc++
and -lm to the host gcc build's LDFLAGS, because at the time the linker
did not correctly include these libraries causing the build to fail.

In modern builds, this causes a problem for canadian gcc builds where
the host machine is mingw32-w64 Windows.

Within the gcc build there is the liblto_plugin module. On Windows this
must be built as the "liblto_plugin.dll" dynamic library. However,
libtool cannot produce a dynamic library unless every library dependency
is also a dynamic library, and falls back to producing a libstdc++.a
static library. liblto_plugin does not require libstdc++ - it
does not contain any C++ code, and the dependency would usually be
elided by the linker.

Unfortunately, in this case, crosstool-ng will never build a
libstdc++.dll dynamic library - only a libstdc++.a static library.
Therefore, there will never be a dynamic library version of stdc++ for
libtool to load and then discard.

This patch corrects the issue by removing "-lstdc++" from LDFLAGS,
because modern versions of gcc are able to correctly include libstdc++
where necessary. It also remove "-lm" for similar reasons.

Signed-off-by: Joel Holdsworth <jholdsworth@nvidia.com>
2022-05-11 20:25:42 +12:00
Norbert Lange
ad3996a483 gcc: add gcc libstdcxx-verbose option
Rather important option for arm cortex toolchains supporting c++,
avoids pulling in all printf/iostream code by default.

Signed-off-by: Norbert Lange <nolange79@gmail.com>
2022-02-23 20:21:16 +13:00
Alexey Neyman
5a0be8b4ec Unify core passes
With libc_headers step before pass-1, there is no need to distinguish
pass-1 and pass-2; they are configured identically (note that with the
current configuration, core pass-2 is only used for win32 - hence, uses
build_libgcc=yes and mode=static).

Signed-off-by: Alexey Neyman <stilor@att.net>
2022-02-11 00:47:51 -08:00
Alexey Neyman
7b97bdd825 Convert tabs to spaces
Recent changes introduced a mixture of tabs/spaces that result in broken
indentation in multiple places.

Signed-off-by: Alexey Neyman <stilor@att.net>
2022-02-11 00:47:51 -08:00
Chris Packham
557b9d4f8d gcc: Build static libgcc in core_pass1
Per https://github.com/crosstool-ng/crosstool-ng/issues/808 build static
libgcc in the first pass which lets us skip the second one.  Building
mingw-w64 requires header files in order to build C++ support so mingw
builds core pass 2. This could probably be cleaned up by splitting
libc_start_files into a separate libc_header step. But for now having
core 2 for mingw-w64 and core 1 for the other libcs will have to do.

Anything that previously selected CC_CORE_PASSES_NEEDED now selects
CC_CORE_PASS_1_NEEDED. The same goes for CC_CORE_PASS_2_NEEDED with the
exception of mingw-w64.

Fixes #808
Fixes #217

Signed-off-by: Chris Packham <judge.packham@gmail.com>
2022-01-12 21:02:38 +13:00
Chris Packham
15635997a1 Merge branch 'canadian-cross-build' of https://github.com/foss-for-synopsys-dwc-arc-processors/crosstool-ng
Signed-off-by: Chris Packham <judge.packham@gmail.com>
2021-09-08 20:26:30 +12:00
Alexey Brodkin
e075bdfc94 gcc: Don't mess with --with-host-libstdcxx if recent GCC (6+) is used
"--with-host-libstdcxx" option was removed in GCC 6.x, see [1] because of [2].
So it makes no sense to use it with later GCC versions.

Frankly I don't like that implementation with yet another set of "if XXX",
but since we still support GCC down to 4.8.5 what else we may do?

Well, technically we may keep using things as they are now,
because surprisingly GCC's configure script doesn't mind accepting
meaningless options, but as a person who's looking at differences between
various builds and drill-down to peculiarities of various config
options, I'd prefer to not pollute configure with garbage.

But for all the rest... well, it works now and maybe nodody else cares.

[1] https://gcc.gnu.org/git/?p=gcc.git&a=commit;h=5dc85f7ec719a79ecfbcdd8563b07e5f0f365e65
[2] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67092

Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
2021-09-07 00:43:36 -07:00
Alexey Brodkin
5c5b4df6d3 gcc: Fix canadian cross building on older hosts
GCC 11+ requires compiler being used to support C++11 standard [1].
And while GCC starting from 6.x has C++11 support enabled by default [2],
older versions need to be forced to implement it with "-std=gnu++11" and luckily
GCC's build-system takes care of that:

 1. For ${host} compiler - [1]
 2. For ${build} compiler - [3, 4]

In a nutshell the configure script tries a couple of options and the one which
helps to build a test source gets appended to CXX (not CXXFLAGS!),
so on say CentOS 7.x with GCC 4.8.5 during cross-compilation of GCC
CXX="x86_64-build_pc-linux-gnu-g++ -std=gnu++11". And all is good.

But in case of canadian cross due to [5] we for some reason* force set
CXX_FOR_BUILD with just a compiler name, effectively overriding all the
magic done by GCC's internals described above.

This leads to a compilation failures like that:
------------------------------------->8----------------------------------
[ALL  ]    In file included from /usr/include/c++/4.8.2/type_traits:35:0,
[ALL  ]                     from .../HOST-x86_64-apple-darwin14/arc-gcc11-elf/src/gcc/gcc/system.h:244,
[ALL  ]                     from .../HOST-x86_64-apple-darwin14/arc-gcc11-elf/src/gcc/gcc/gengtype.c:26:
[ERROR]    /usr/include/c++/4.8.2/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
[ALL  ]     #error This file requires compiler and library support for the   ^
------------------------------------->8----------------------------------

* my guess that [5] was done because back in the day indeed we used to have
"--build=${CT_BUILD} --host=${CT_HOST}" in do_cc_core(). But now after [6]
this is no longer necessary as we use "--build=${CT_BUILD} --host=${CT_BUILD}"
and all is safe and clean. So yet another old quirk goes away - hooray!

[1] https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=5329b59a2e13dabbe2038af0fe2e3cf5fc7f98ed
[2] https://gcc.gnu.org/gcc-6/changes.html
[3] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96612
[4] https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=7ffcf5d61174dda1f39a623e15f7e5d6b98bbafc
[5] 9c6c090d7b
[6] 08161250ed

Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
2021-09-06 23:21:21 -07:00
Chris Packham
b346fa58b1 cc/gcc: Add options for zstd usage
GCC can support using zstd compression for LTO object files. By default
GCC's configure will enable this if libzstd is installed on the machine
building the toolchain. This may be undesirable if the toolchain is to
be used on a different machine. Add an option to control zstd usage and
set the default to the same as the current behaviour (i.e. auto).

Fixes #1579

Signed-off-by: Chris Packham <judge.packham@gmail.com>
2021-08-29 21:27:29 +12:00
Raphael Catolino
c3b13ffdda Add EXTRA_CXXFLAGS_FOR_BUILD option
Signed-off-by: Raphael Catolino <raphael.catolino@gmail.com>
2021-07-06 16:19:17 +01:00
Chris Packham
96d8a0588f gcc: Make CC_GCC_TM_CLONE_REGISTRY tristate
Explicitly passing --disable-tm-clone-registry causes gcc to create a
crtbegin.o with a zero-sized .init_array/.fini_array. This in turn
causes ld to complain.

Make CC_GCC_TM_CLONE_REGISTRY a tristate so if it's not explicitly
enabled we can let ./configure decide.

Fixes #1531

Fixes: 1e21a302 ("gcc: Add CT_CC_GCC_TM_CLONE_REGISTRY config")
Signed-off-by: Chris Packham <judge.packham@gmail.com>
2021-06-20 11:37:00 +12:00
Chris Packham
594b9286f4
Merge pull request #1524 from stephanosio/gcc_custom_libstdcpp_cxx_flags_upstream
Fix libstdc++ build options
2021-06-09 20:11:48 +12:00
Stephanos Ioannidis
1e21a30287 gcc: Add CT_CC_GCC_TM_CLONE_REGISTRY config
This commit adds a new gcc config `CT_CC_GCC_TM_CLONE_REGISTRY` that
enables the GCC transactional memory clone registry feature for libgcc.

Note that the gcc option to control this feature is only available in
gcc 10 and above.
(see gcc commit 5a4602805eb3ebddbc935b102481e63bffc7c5e6)

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2021-06-08 02:13:45 +09:00
Stephanos Ioannidis
fffa4c5aa5 gcc: Allow setting custom target CXXFLAGS
This commit adds two additional arguments (`cxxflags_for_target` and
`extra_cxxflags_for_target`) for the gcc backend build function that
can be used to specify custom target CXXFLAGS.

By default, the target CXXFLAGS is set to the target CFLAGS. When
`cxxflags_for_target` is specified however, it overrides that behaviour
and allows setting different target CXXFLAGS from the target CFLAGS.

The `extra_cxxflags_for_target` argument can be used to specify the
extra target CXXFLAGS to be appended to the target CXXFLAGS. This is
useful when it is necessary to append CXX-specific flags to the
existing CFLAGS to be used as the target CXXFLAGS.

A useful application of this is building full and nano versions of
libstdc++ with different target CXXFLAGS as necessitated by
`nano.specs`.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2021-06-07 19:53:28 +09:00
Stephanos Ioannidis
3c637c1eec gcc: Assume '-O2' by default for building gcc target libraries
The gcc target libraries (e.g. libstdc++) are currently built without
any optimisation flag when `CT_CC_GCC_ENABLE_TARGET_OPTSPACE` is not
enabled and default to `-O0` unless user explicitly specifies an
optimisation flag.

This commit updates the gcc build script to assume `-O2` for building
target libraries unless user provides a different optimisation flag.

Note also that this is the default behaviour for gcc when
C[XX]FLAGS_FOR_TARGET is not overridden.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2021-06-07 19:52:58 +09:00
Ivan Kukhta
8b4373d4ee Extend CC_GCC_LIBSSP with manual state
Signed-off-by: Ivan Kukhta <Ivan.Kukhta@acronis.com>
2021-03-17 13:50:45 +03:00
Chris Packham
e64318656c Merge branches 'elijahr-dtc-1.6.0', 'elijahr-readme-typo', 'foss-for-synopsys-dwc-arc-processors-abrodkin-libgmp-for-mac' and 'keith-packard-picolibc-companion' 2021-01-13 19:50:23 +13:00
Keith Packard
43f5079382 gcc: Add support for building libstdc++ with alternate libc
This adds another mode to do_gcc_core_backend that builds libstdc++
against an alternate libc implementation.

Signed-off-by: Keith Packard <keithp@keithp.com>
2021-01-11 22:48:46 -08:00
Alexey Brodkin
b833f45259 gcc: Make it aware of Newlib nano IO feature
Even though GCC as a compiler has nothing to do with a C library
being used it still makes sense to know about Newlib's compact
implementation of IO functions:

 * For targets like MSP430 which require to have such a tuned
   Newlib if "-mtiny-printf" is passed to the GCC's command-line [1]

 * For correct compilation of the following GCC's own DejaGnu tests [2]:
     - gcc/testsuite/gcc.c-torture/execute/920501-8.c
     - gcc/testsuite/gcc.c-torture/execute/930513-1.c
     - gcc/testsuite/gcc.dg/torture/builtin-sprintf.c
     - gcc/testsuite/gcc.c-torture/execute/ieee/920810-1.x

[1] https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=02afb6a9321fbfb435452636cedc2cd43f0c4fd2
[2] https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=571bbd0d48d5872eacbd0b681fce6e1ae754520b

So we add that missing cross-dependency now.

Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
2020-12-23 17:54:03 +03:00
Alexey Neyman
d978290f39 Set --with-cpu-{32,64} for multilib builds
GLIBC 2.31 needs --with-cpu=ultrasparc for both 32/64-bits now, and
--with-cpu only sets the CPU model for the "primary" bitness.

Signed-off-by: Alexey Neyman <stilor@att.net>
2020-02-26 11:05:19 -08:00
Alexey Neyman
693d3943b1 Rename JOBSFLAGS -> CT_JOBSFLAGS
... so that it is saved/restored when restarting the build.

Signed-off-by: Alexey Neyman <stilor@att.net>
2019-04-04 18:57:42 -07:00
Alexey Neyman
a0249703fd Duh! do not override ${cflags}
... in the backend function with ${CFLAGS_FOR_HOST}. The caller either
supplies them already, or (in case of pass-1/2 of the canadian cross)
passes ${CFLAGS_FOR_BUILD} there.

Signed-off-by: Alexey Neyman <stilor@att.net>
2019-02-19 17:38:21 -08:00
Alexey Neyman
32dd66a35a Use -idirafter instead of copying headers.
Signed-off-by: Alexey Neyman <stilor@att.net>
2019-02-17 16:57:57 -08:00
Alexey Neyman
2219aab336 Implement an option to store downloads in subdirs
... following the buildroot model.

Signed-off-by: Alexey Neyman <stilor@att.net>
2019-02-13 01:05:13 -08:00
Alexey Neyman
e05fa86bba Canonicalize prefix dir and sysroot
... because GCC prints the sysroot with symlinks resolved.

Fixes #892.

Signed-off-by: Alexey Neyman <stilor@att.net>
2019-01-14 23:56:40 -08:00
Alexey Neyman
f2b64524b0 Add a symlink to LTO for binutils
... so that ar can find the plugin even when invoked directly, not
via the gcc-ar plugin.

Signed-off-by: Alexey Neyman <stilor@att.net>
2018-12-11 08:55:07 -08:00
Alexey Neyman
9d2a5f8413 Set ALL_TARGET_CFLAGS initially for !MULTILIB
Fixes #1107.

Signed-off-by: Alexey Neyman <stilor@att.net>
2018-12-07 00:03:04 -08:00
Alexey Neyman
2808fdb6a3
Merge pull request #985 from antmak/platform_headers
Use the platform headers in the pass-2 and canadian gcc stages
2018-11-03 15:38:51 -07:00
Alexey Neyman
782b45d0da Supply "very old" and "very new" glibc versions
... as 1.0 and 99.99, respectively, to gcc configure.

Fixes #1031.

Signed-off-by: Alexey Neyman <stilor@att.net>
2018-10-21 19:05:19 -07:00
Anton Maklakov
1dea24ce9a Use the platform headers in the pass-2 and canadian gcc stages 2018-06-12 17:07:06 +08:00
Alexey Neyman
07ec87f14f Avoid adding arch/cpu/tune flags for target to GCC build
... as it may need to override them for building runtime-selectable code.

Signed-off-by: Alexey Neyman <stilor@att.net>
2018-06-05 00:16:37 -07:00