Skip to content

Commit

Permalink
GCC: use --enable-host-shared
Browse files Browse the repository at this point in the history
Building 'static GCC' now correctly means to build GCC with static host libraries instead of static target libraries since it runs on host, not target.
  • Loading branch information
Prince213 committed Aug 11, 2021
1 parent 349b405 commit 4b15c31
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 49 deletions.
6 changes: 2 additions & 4 deletions build
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ while [[ $# > 0 ]]; do
--no-strip) STRIP_ON_INSTALL=no ;;
--static-gcc)
BOOTSTRAPING=yes
LINK_TYPE_GCC=$LINK_TYPE_STATIC
LINK_TYPE_GCC=$LINK_TYPE_GCC_STATIC
GCC_DEPS_LINK_TYPE=$LINK_TYPE_STATIC
BUILD_SHARED_GCC=no
LINK_TYPE_SUFFIX=static
Expand Down Expand Up @@ -879,10 +879,8 @@ for rule in ${SUBTARGETS[@]}; do
_reverse_arch=$(func_get_reverse_arch $BUILD_ARCHITECTURE)
_reverse_bits=$(func_get_reverse_arch_bit $BUILD_ARCHITECTURE)
mkdir -p $TESTS_ROOT_DIR/${_reverse_arch}
[[ $BUILD_SHARED_GCC == yes ]] && {
cp -f $( find $PREFIX/$TARGET/lib${_reverse_bits} -type f \( -iname *.dll \) ) \
cp -f $( find $PREFIX/$TARGET/lib${_reverse_bits} -type f \( -iname *.dll \) ) \
$TESTS_ROOT_DIR/${_reverse_arch}/
}
}
for test in "${!PKG_TESTS[@]}"; do
func_test $test ${PKG_TESTS[$test]} $TESTS_ROOT_DIR
Expand Down
5 changes: 3 additions & 2 deletions library/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,11 @@ PROCESSOR_OPTIMIZATION_ARCH_64='nocona'

# **************************************************************************

LINK_TYPE_BOTH="--enable-shared --enable-static"
LINK_TYPE_SHARED="--enable-shared --disable-static"
LINK_TYPE_STATIC="--enable-static --disable-shared"
LINK_TYPE_GCC=$LINK_TYPE_BOTH
LINK_TYPE_GCC_SHARED="--enable-host-shared"
LINK_TYPE_GCC_STATIC="--disable-host-shared"
LINK_TYPE_GCC=$LINK_TYPE_GCC_SHARED
GCC_DEPS_LINK_TYPE=$LINK_TYPE_STATIC

ENABLE_LANGUAGES='c,c++,fortran'
Expand Down
5 changes: 4 additions & 1 deletion scripts/binutils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,10 @@ PKG_CONFIGURE_FLAGS=(
--disable-nls
--disable-shared
#
$LINK_TYPE_GCC
$( [[ $BUILD_SHARED_GCC == yes ]] \
&& echo "$LINK_TYPE_SHARED" \
|| echo "$LINK_TYPE_STATIC"
)
#
CFLAGS="\"$COMMON_CFLAGS\""
CXXFLAGS="\"$COMMON_CXXFLAGS\""
Expand Down
1 change: 1 addition & 0 deletions scripts/gcc-11.2.0.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ PKG_CONFIGURE_FLAGS=(
--with-sysroot=$PREFIX
#--with-gxx-include-dir=$MINGWPREFIX/$TARGET/include/c++
#
--enable-shared
$LINK_TYPE_GCC
#
$( [[ $USE_MULTILIB == yes ]] \
Expand Down
72 changes: 30 additions & 42 deletions scripts/gcc-post.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,70 +61,58 @@ function gcc_post_install {

local _gcc_version=$(func_map_gcc_name_to_gcc_version $_GCC_NAME)
local _reverse_bits=$(func_get_reverse_arch_bit $BUILD_ARCHITECTURE)
[[ $BUILD_SHARED_GCC == yes ]] && {
# libgcc_s.a
cp -f $PREFIX/lib/gcc/$TARGET/lib/libgcc_s.a $PREFIX/$TARGET/lib/ \
|| die "Cannot copy libgcc_s.a to $PREFIX/$TARGET/lib"
}
# libgcc_s.a
cp -f $PREFIX/lib/gcc/$TARGET/lib/libgcc_s.a $PREFIX/$TARGET/lib/ \
|| die "Cannot copy libgcc_s.a to $PREFIX/$TARGET/lib"

func_has_lang objc
local is_objc=$?
[[ $is_objc == 1 ]] && {
# libobjc
cp -f $BUILDS_DIR/$_GCC_NAME/$TARGET/libobjc/.libs/libobjc.a $PREFIX/lib/gcc/$TARGET/$_gcc_version/ \
|| die "Cannot copy libobjc.a to $PREFIX/lib/gcc/$TARGET/$_gcc_version"
[[ $BUILD_SHARED_GCC == yes ]] && {
cp -f $BUILDS_DIR/$_GCC_NAME/$TARGET/libobjc/.libs/libobjc.dll.a $PREFIX/lib/gcc/$TARGET/$_gcc_version/ \
|| die "Cannot copy libobjc.dll.a to $PREFIX/lib/gcc/$TARGET/$_gcc_version"
}
cp -f $BUILDS_DIR/$_GCC_NAME/$TARGET/libobjc/.libs/libobjc.dll.a $PREFIX/lib/gcc/$TARGET/$_gcc_version/ \
|| die "Cannot copy libobjc.dll.a to $PREFIX/lib/gcc/$TARGET/$_gcc_version"
# objc headers
cp -rf ${SRCS_DIR}/$_GCC_NAME/libobjc/objc $PREFIX/lib/gcc/$TARGET/$_gcc_version/include \
|| die "Cannot copy objc headers to $PREFIX/lib/gcc/$TARGET/$_gcc_version/include"
}

[[ $BUILD_SHARED_GCC == yes ]] && {
# builded architecture dlls
local _dlls=( $(find $BUILDS_DIR/$_GCC_NAME/$TARGET \
-not \( -path $BUILDS_DIR/$_GCC_NAME/$TARGET/32 -prune \) \
-not \( -path $BUILDS_DIR/$_GCC_NAME/$TARGET/64 -prune \) \
-not \( -path $BUILDS_DIR/$_GCC_NAME/gcc/ada -prune \) \
-not \( -path $BUILDS_DIR/$_GCC_NAME/$TARGET/libada/adainclude -prune \) \
-type f -name *.dll) )
cp -f ${_dlls[@]} $PREFIX/bin/ > /dev/null 2>&1 || die "Cannot copy architecture dlls to $PREFIX/bin/"
cp -f ${_dlls[@]} $PREFIX/$TARGET/lib/ > /dev/null 2>&1 || die "Cannot copy architecture dlls to $PREFIX/lib/"

[[ $STRIP_ON_INSTALL == yes ]] && {
strip $PREFIX/bin/*.dll || die "Error stripping dlls from $PREFIX/bin"
strip $PREFIX/$TARGET/lib/*.dll || die "Error stripping dlls from $PREFIX/$TARGET/lib"
}
# builded architecture dlls
local _dlls=( $(find $BUILDS_DIR/$_GCC_NAME/$TARGET \
-not \( -path $BUILDS_DIR/$_GCC_NAME/$TARGET/32 -prune \) \
-not \( -path $BUILDS_DIR/$_GCC_NAME/$TARGET/64 -prune \) \
-not \( -path $BUILDS_DIR/$_GCC_NAME/gcc/ada -prune \) \
-not \( -path $BUILDS_DIR/$_GCC_NAME/$TARGET/libada/adainclude -prune \) \
-type f -name *.dll) )
cp -f ${_dlls[@]} $PREFIX/bin/ > /dev/null 2>&1 || die "Cannot copy architecture dlls to $PREFIX/bin/"
cp -f ${_dlls[@]} $PREFIX/$TARGET/lib/ > /dev/null 2>&1 || die "Cannot copy architecture dlls to $PREFIX/lib/"

[[ $STRIP_ON_INSTALL == yes ]] && {
strip $PREFIX/bin/*.dll || die "Error stripping dlls from $PREFIX/bin"
strip $PREFIX/$TARGET/lib/*.dll || die "Error stripping dlls from $PREFIX/$TARGET/lib"
}
[[ $USE_MULTILIB == yes ]] && {
[[ $BUILD_SHARED_GCC == yes ]] && {
# libgcc_s.a
cp -f $PREFIX/lib/gcc/$TARGET/lib$_reverse_bits/libgcc_s.a $PREFIX/$TARGET/lib$_reverse_bits/ \
|| die "Cannot copy libgcc_s.a to $PREFIX/$TARGET/lib${_reverse_bits}/"
}
# libgcc_s.a
cp -f $PREFIX/lib/gcc/$TARGET/lib$_reverse_bits/libgcc_s.a $PREFIX/$TARGET/lib$_reverse_bits/ \
|| die "Cannot copy libgcc_s.a to $PREFIX/$TARGET/lib${_reverse_bits}/"

[[ $is_objc == 1 ]] && {
# libobjc libraries
cp -f $BUILDS_DIR/$_GCC_NAME/$TARGET/$_reverse_bits/libobjc/.libs/libobjc.a $PREFIX/lib/gcc/$TARGET/$_gcc_version/$_reverse_bits/ \
|| die "Cannot copy libobjc.a to $PREFIX/lib/gcc/$TARGET/$_gcc_version/${_reverse_bits}"
[[ $BUILD_SHARED_GCC == yes ]] && {
cp -f $BUILDS_DIR/$_GCC_NAME/$TARGET/$_reverse_bits/libobjc/.libs/libobjc.dll.a $PREFIX/lib/gcc/$TARGET/$_gcc_version/$_reverse_bits/ \
|| die "Cannot copy libobjc.dll.a to $PREFIX/lib/gcc/$TARGET/$_gcc_version/${_reverse_bits}"
}
cp -f $BUILDS_DIR/$_GCC_NAME/$TARGET/$_reverse_bits/libobjc/.libs/libobjc.dll.a $PREFIX/lib/gcc/$TARGET/$_gcc_version/$_reverse_bits/ \
|| die "Cannot copy libobjc.dll.a to $PREFIX/lib/gcc/$TARGET/$_gcc_version/${_reverse_bits}"
}

[[ $BUILD_SHARED_GCC == yes ]] && {
# Second architecture bit dlls
find $BUILDS_DIR/$_GCC_NAME/$TARGET/$_reverse_bits \
-not \( -path $BUILDS_DIR/$_GCC_NAME/$TARGET/$_reverse_bits/libada/adainclude -prune \) \
-type f -name *.dll ! -name *winpthread* -print0 \
| xargs -0 -I{} cp -f {} $PREFIX/$TARGET/lib$_reverse_bits/ || die "Error copying ${_reverse_bits}-bit dlls"
# Second architecture bit dlls
find $BUILDS_DIR/$_GCC_NAME/$TARGET/$_reverse_bits \
-not \( -path $BUILDS_DIR/$_GCC_NAME/$TARGET/$_reverse_bits/libada/adainclude -prune \) \
-type f -name *.dll ! -name *winpthread* -print0 \
| xargs -0 -I{} cp -f {} $PREFIX/$TARGET/lib$_reverse_bits/ || die "Error copying ${_reverse_bits}-bit dlls"

[[ $STRIP_ON_INSTALL == yes ]] && {
strip $PREFIX/$TARGET/lib$_reverse_bits/*.dll || die "Error stripping ${_reverse_bits}-bit dlls"
}
[[ $STRIP_ON_INSTALL == yes ]] && {
strip $PREFIX/$TARGET/lib$_reverse_bits/*.dll || die "Error stripping ${_reverse_bits}-bit dlls"
}
}

Expand Down

0 comments on commit 4b15c31

Please sign in to comment.