sylware / nyanlinux (public) (License: AFFERO GPLv3) (since 2019-09-09) (hash sha1)
scripts for a lean, from scratch, amd hardware, linux distro

/builders/gcc-common/fragments.sh (275fb4ca1497907a4d899bdb79c16eb14755f8be) (5850 bytes) (mode 100644) (type blob)

# YOU MUST READ THIS FIRST:
# there are _TWO_ sysroot:
#	- the build sysroot: cross-compiling a compiler
#	- the sysroot: for any cross-compiler
# there are many bugs related to the configuration of those sysroots

# ALWAYS THINK LIKE YOU ARE CROSS-COMPLING A CROSS-COMPILER ("CANADIAN BUILD")
#                             **** ALWAYS *****

# This is the top level configure for the gcc source tree which actually does
# _global_ configuration and records some specific options you want to pass to
# the configuration stage of the actual gcc and related pieces of software,
# namely to know exactly how the real packages are configured, it is done in
# the top makefile. As of today, you cannot modularize the different
# sub-packages cleanly, coze depending on their configuration, they will use
# some stuff _inside_ the other packages. THIS IS *INSANE BAD DESIGN FOR THE
# CORE OF A GNU/LINUX SYSTEM* since in the middle of all that, *YOU NEED* an
# external component: the glibc!! Proper design: break gcc in ACTUAL modules,
# to make the glibc just one of them, God Damn It!
# native-system-header-dir is relative to sysroot (for a cross compiler)
opts_common="\
	--enable-serial-configure							\
	--disable-bootstrap								\
	--target=$target_gnu_triple							\
	--enable-threads=posix								\
	--disable-decimal-float								\
	--disable-fixed-point								\
	--disable-plugin								\
	--disable-multilib								\
	--disable-multiarch								\
	--disable-vtable-verify								\
	--disable-libquadmath								\
	--disable-libquadmath-support							\
	--disable-libada								\
	--disable-libgomp								\
	--disable-libatomic								\
	--disable-libcilkrts								\
	--disable-libitm								\
	--disable-libsanitizer								\
	--disable-libmpx								\
	--disable-libhsail-rt								\
	--disable-libstdcxx-pch								\
	--disable-lto									\
	--disable-nls									\
	--disable-libssp								\
	--disable-default-ssp								\
	--enable-link-mutex
"

# don't let sysroot empty
# The prefix *MUST* be the same than the binutils one or gcc won't find them at
# runtime.
build_opts_common="\
	--with-gmp=$cross_toolchain_dir_root				\
	--with-mpfr=$cross_toolchain_dir_root				\
	--with-mpc=$cross_toolchain_dir_root				\
	--with-sysroot=$target_sysroot					\
"

cross_static_target_libgcc_gcc_c_configure()
{
export 'CFLAGS=-O2 -pipe -fPIC'
export "CFLAGS_FOR_TARGET=-fPIC -O2 -pipe"
$src_dir/configure										\
	--prefix=$cross_toolchain_static_target_libgcc_dir_root					\
	--with-build-time-tools=$cross_toolchain_static_target_libgcc_dir_root			\
	--with-native-system-header-dir=/nyan/glibc/0/include-static-target-libgcc-linux	\
	--enable-languages=c									\
	--disable-shared									\
	$build_opts_common									\
	$opts_common
unset CFLAGS_FOR_TARGET
unset CFLAGS
}

cross_gcc_compilers_configure()
{
export 'CFLAGS=-O2 -pipe -fPIC'
export 'CXXFLAGS=-O2 -pipe -fPIC'
# at link time, the only way to tell gnu ld where to look for shared lib dependencies is to pass the -rpath-link option
export "CFLAGS_FOR_TARGET=-O2 -pipe -fPIC -B$target_sysroot/nyan/glibc/0/lib -L$target_sysroot/nyan/glibc/0/lib -Wl,-rpath-link,$target_sysroot/nyan/glibc/current/lib -I$target_sysroot/nyan/glibc/0/include-linux"
export "CXXFLAGS_FOR_TARGET=-O2 -pipe -fPIC -B$target_sysroot/nyan/glibc/0/lib -L$target_sysroot/nyan/glibc/0/lib -Wl,-rpath-link,$target_sysroot/nyan/glibc/current/lib -I$target_sysroot/nyan/glibc/0/include-linux"
$src_dir/configure								\
	--prefix=$cross_toolchain_dir_root					\
	--with-build-time-tools=$cross_toolchain_dir_root			\
	--with-native-system-header-dir=/nyan/glibc/0/include-linux		\
	--enable-languages=c,c++						\
	$build_opts_common							\
	$opts_common
unset CXXFLAGS_FOR_TARGET
unset CFLAGS_FOR_TARGET
unset CXXFLAGS
unset CFLAGS
}

# this is to cross-compile gcc itself
# **** WARNING **** gcc fixinclude usage will _NOT_ honor the build_sysroot
# variable before gcc 8: then when cross-compiling a native compiler, it will
# look in the build system root for the target/native system headers (for gcc
# <8), if this dir is not defined with --with-native-system-header-dir, it will
# default to /usr/include dir (!!)
# this path will be wrongly hardcoded in gcc/cpp include search path list
gcc_compilers_cross_configure()
{
# at link time, the only way to tell gnu ld where to look for shared lib dependencies is to pass the -rpath-link option
export "CC=$target_gnu_triple-gcc -B$target_sysroot/nyan/glibc/0/lib -L$target_sysroot/nyan/glibc/0/lib -Wl,-rpath-link,$target_sysroot/nyan/glibc/current/lib -static-libgcc"
export 'CFLAGS=-O2 -pipe -fPIC'
export "CXX=$target_gnu_triple-g++ -B$target_sysroot/nyan/glibc/0/lib -L$target_sysroot/nyan/glibc/0/lib -Wl,-rpath-link,$target_sysroot/nyan/glibc/current/lib -static-libgcc -static-libstdc++"
export 'CXXFLAGS=-O2 -pipe -fPIC'
export "CFLAGS_FOR_TARGET=-fPIC -O2 -B$target_sysroot/nyan/glibc/0/lib -L$target_sysroot/nyan/glibc/0/lib -Wl,-rpath-link,$target_sysroot/nyan/glibc/current/lib"
export "CXXFLAGS_FOR_TARGET=-fPIC -O2 -B$target_sysroot/nyan/glibc/0/lib -L$target_sysroot/nyan/glibc/0/lib -Wl,-rpath-link,$target_sysroot/nyan/glibc/current/lib"
# **** WARNING ****:the slibdir will be modified with the "multiosdir" from the
# cross compiler, usually, lib64...
$src_dir/configure								\
	--build=$build_gnu_triple						\
	--host=$target_gnu_triple						\
	--enable-languages=c,c++						\
	$opts_common								\
	--prefix=/nyan/toolchains/0						\
	--with-slibdir=/nyan/toolchains/0/lib					\
	--with-native-system-header-dir=/nyan/glibc/current/include-linux	\
	--with-build-sysroot=$target_sysroot					\
	--with-gmp=$target_sysroot/nyan/toolchains/0				\
	--with-mpfr=$target_sysroot/nyan/toolchains/0				\
	--with-mpc=$target_sysroot/nyan/toolchains/0
unset CXXFLAGS_FOR_TARGET
unset CFLAGS_FOR_TARGET
unset CXXFLAGS
unset CFLAGS
}


Mode Type Size Ref File
100644 blob 5 8eba6c8dd4dcaf6166bd22285ed34625f38a84ff .gitignore
100755 blob 1587 57fa4264b9ee0ae0a6f678f2527a05d3b22dda78 00-bootstrap-build.sh
100755 blob 848 a30f443bf405d56682efe3b4c5d3a19d5f7eb45d 01-re-bootstrap-build.sh
100644 blob 2142 f19c2d6b293244bb11a3f74ee77c10675cadc7d6 INSTALL
100644 blob 30 c9b735fa1332286f4b3f5f81fa10527fd7506b6e LICENSE
040000 tree - b2f9205e1ca688ebdc08741a5fa512fbbd37de94 builders
100644 blob 1773 ef1551089a803bde37e36edc8d61bb819d06f793 conf.bootstrap.sh
100644 blob 479 8cc15efe46965ac7750fe304460f5a2b0aa4201c conf.sh
040000 tree - 37fb4df620fed5aaca7f238f575dacc41ad90178 files
100755 blob 356 8fb8be28ac72f7214b59934b9f74a682665f2d32 pkg-build
100644 blob 22800641 e9e6291054c857401f6835c728f31541dae4311e steam.tar.bz2
100644 blob 173 2047af328b22f9d146585cd9e759edbc18122250 utils.sh
040000 tree - 8e23f551092a35f82b37129dd08c35c4d313c17b x64
040000 tree - b7a22de7f5cbd97650dd45412ef7d4246e395eb8 x86
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/sylware/nyanlinux

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/sylware/nyanlinux

Clone this repository using git:
git clone git://git.rocketgit.com/user/sylware/nyanlinux

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main