6063a8fbcf
Currently, the internal toolchain backend does a three stage gcc build, with the following sequence of builds: - build gcc-initial - configure libc, install headers and start files - build gcc-intermediate - build libc - build gcc-final However, it turns out that this is not necessary, and only a two stage gcc build is needed. At some point, it was believed that a three stage gcc build was needed for NPTL based toolchains with old gcc versions, but even a gcc 4.4 build with a NPTL toolchain works fine. So, this commit switches the internal toolchain backend to use a two stage gcc build: just gcc-initial and gcc-final. It does so by: * Removing the custom dependency of all C libraries build step to host-gcc-intermediate. Now the C library packages simply have to depend on host-gcc-initial as a normal dependency (which they already do), and that's it. * Build and install both gcc *and* libgcc in host-gcc-initial. Previously, only gcc was built and installed in host-gcc-initial. libgcc was only done in host-gcc-intermediate, but now we need libgcc to build the C library. * Pass appropriate environment variables to get SSP (Stack Smashing Protection) to work properly: - Tell the compiler that the libc will provide the SSP support, by passing gcc_cv_libc_provides_ssp=yes. In Buildroot, we have chosen to use the SSP support from the C library instead of the SSP support from the compiler (this is not changed by this patch series, it was already the case). - Tell glibc to *not* build its own programs with SSP support. The issue is that if glibc detects that the compiler supports -fstack-protector, then glibc uses it to build a few things with SSP. However, at this point, the support is not complete (we only have host-gcc-initial, and the C library is not completely built). So, we pass libc_cv_ssp=no to tell the C library to not use SSP support itself. Note that this is not a big loss: only a few parts of the C library were built with -fstack-protector, not the entire library. * A special change is needed for ARC, because its libgcc depends on the C library, which breaks building libgcc in host-gcc-initial. This looks like a bug in the ARC compiler, as it does not obey the inhibit_libc variable which tells the compiler build process to *not* enable things that depend on the C library. So for now, in host-gcc-initial, we simply disable the build of libgmon.a for ARC. It's going to be built as part of host-gcc-final, so the final compiler will have gmon support. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
71 lines
2.4 KiB
Makefile
71 lines
2.4 KiB
Makefile
################################################################################
|
|
#
|
|
# musl
|
|
#
|
|
################################################################################
|
|
|
|
MUSL_VERSION = 1.1.4
|
|
MUSL_SITE = http://www.musl-libc.org/releases
|
|
MUSL_LICENSE = MIT
|
|
MUSL_LICENSE_FILES = COPYRIGHT
|
|
|
|
# Before musl is configured, we must have the first stage
|
|
# cross-compiler and the kernel headers
|
|
MUSL_DEPENDENCIES = host-gcc-initial linux-headers
|
|
|
|
# musl is part of the toolchain so disable the toolchain dependency
|
|
MUSL_ADD_TOOLCHAIN_DEPENDENCY = NO
|
|
|
|
MUSL_INSTALL_STAGING = YES
|
|
|
|
# We need to run the musl configure script prior to building the
|
|
# gcc-intermediate, so that we can call the install-headers step and
|
|
# get the crt<X>.o built. However, we need to call it again after
|
|
# gcc-intermediate has been built, otherwise the configure script
|
|
# doesn't realize that libgcc has been built, and doesn't link the C
|
|
# library properly with libgcc, which causes build failure down the
|
|
# road. We will have the opportunity to simplify this once we switch
|
|
# to a 2-steps gcc build.
|
|
define MUSL_CONFIGURE_CALL
|
|
(cd $(@D); \
|
|
$(TARGET_CONFIGURE_OPTS) \
|
|
CFLAGS="$(filter-out -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64,$(TARGET_CFLAGS)) $(MUSL_EXTRA_CFLAGS)" \
|
|
CPPFLAGS="$(filter-out -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64,$(TARGET_CPPFLAGS))" \
|
|
./configure \
|
|
--target=$(GNU_TARGET_NAME) \
|
|
--host=$(GNU_TARGET_NAME) \
|
|
--prefix=/usr \
|
|
--disable-gcc-wrapper)
|
|
endef
|
|
|
|
define MUSL_CONFIGURE_CMDS
|
|
$(MUSL_CONFIGURE_CALL)
|
|
$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) \
|
|
DESTDIR=$(STAGING_DIR) install-headers
|
|
$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) \
|
|
crt/crt1.o crt/crti.o crt/crtn.o
|
|
cp $(@D)/crt/crt*.o $(STAGING_DIR)/usr/lib
|
|
$(TARGET_CROSS)gcc -nostdlib \
|
|
-nostartfiles -shared -x c /dev/null -o $(STAGING_DIR)/usr/lib/libc.so
|
|
endef
|
|
|
|
define MUSL_BUILD_CMDS
|
|
$(MUSL_CONFIGURE_CALL)
|
|
$(TARGET_MAKE_ENV) $(MAKE) -C $(@D)
|
|
endef
|
|
|
|
define MUSL_INSTALL_STAGING_CMDS
|
|
$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) \
|
|
DESTDIR=$(STAGING_DIR) install-libs install-tools
|
|
endef
|
|
|
|
# prefix is set to an empty value to get the C library installed in
|
|
# /lib and not /usr/lib
|
|
define MUSL_INSTALL_TARGET_CMDS
|
|
$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) \
|
|
DESTDIR=$(TARGET_DIR) prefix= install-libs
|
|
$(RM) $(addprefix $(TARGET_DIR)/lib/,crt1.o crtn.o crti.o Scrt1.o)
|
|
endef
|
|
|
|
$(eval $(generic-package))
|