Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Build libsodium with -fPIC for relocatable symbols. #238

Merged
merged 1 commit into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions qtox/build_opus.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ readonly SCRIPT_DIR="$(dirname "$(realpath "$0")")"

source "$SCRIPT_DIR/build_utils.sh"

parse_arch --dep "opus" --supported "linux-x86_64 win32 win64 macos-x86_64 macos-arm64" "$@"
parse_arch --dep "opus" --supported "linux-aarch64 linux-x86_64 win32 win64 macos-x86_64 macos-arm64 ios-arm64" "$@"

if [ "$LIB_TYPE" = "shared" ]; then
ENABLE_STATIC=--disable-static
Expand All @@ -24,7 +24,7 @@ fi
"$SCRIPT_DIR/download/download_opus.sh"

LDFLAGS="-fstack-protector $CROSS_LDFLAG" \
CFLAGS="-O2 -g0 $CROSS_CFLAG" \
CFLAGS="-O2 -fPIC -g0 $CROSS_CFLAG" \
./configure "$HOST_OPTION" \
"--prefix=$DEP_PREFIX" \
"$ENABLE_STATIC" \
Expand Down
11 changes: 6 additions & 5 deletions qtox/build_sodium.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ readonly SCRIPT_DIR="$(dirname "$(realpath "$0")")"

source "$SCRIPT_DIR/build_utils.sh"

parse_arch --dep "sodium" --supported "linux-x86_64 win32 win64 macos-x86_64 macos-arm64" "$@"
parse_arch --dep "sodium" --supported "linux-aarch64 linux-x86_64 win32 win64 macos-x86_64 macos-arm64 ios-arm64" "$@"

if [ "$LIB_TYPE" = "shared" ]; then
ENABLE_STATIC=--disable-static
Expand All @@ -28,12 +28,13 @@ for sym in blake2b blake2b_final blake2b_init blake2b_init_key blake2b_init_para
RENAME_CFLAGS="$RENAME_CFLAGS -D$sym=sodium_$sym"
done

CFLAGS="-O3 $CROSS_CFLAG $RENAME_CFLAGS" \
LDFLAGS="$CROSS_LDFLAG -fstack-protector" \
./configure "$HOST_OPTION" \
./configure "$HOST_OPTION" \
--prefix="$DEP_PREFIX" \
--disable-pie \
"$ENABLE_STATIC" \
"$ENABLE_SHARED"
"$ENABLE_SHARED" \
CFLAGS="-O3 -fPIC $CROSS_CFLAG $RENAME_CFLAGS" \
LDFLAGS="$CROSS_LDFLAG -fstack-protector"

make -j "$MAKE_JOBS"
make install
22 changes: 18 additions & 4 deletions qtox/build_utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ parse_arch() {
SANITIZE=
EXTRA_ARGS=()
MACOS_MINIMUM_SUPPORTED_VERSION=12.0
IOS_MINIMUM_SUPPORTED_VERSION=10.0

while (($# > 0)); do
case $1 in
Expand Down Expand Up @@ -87,6 +88,7 @@ parse_arch() {

assert_supported "$SCRIPT_ARCH" "$SUPPORTED"
export MACOS_MINIMUM_SUPPORTED_VERSION
export IOS_MINIMUM_SUPPORTED_VERSION

if [ "$SCRIPT_ARCH" == "win32" ] || [ "$SCRIPT_ARCH" == "win64" ]; then
if [ "$SCRIPT_ARCH" == "win32" ]; then
Expand All @@ -106,10 +108,22 @@ parse_arch() {
DEP_PREFIX="${DEP_PREFIX:-/work}"
mkdir -p "$DEP_PREFIX"
HOST_OPTION=''
CROSS_LDFLAG="-mmacosx-version-min=$MACOS_MINIMUM_SUPPORTED_VERSION"
CROSS_CFLAG="-mmacosx-version-min=$MACOS_MINIMUM_SUPPORTED_VERSION"
CROSS_CPPFLAG="-mmacosx-version-min=$MACOS_MINIMUM_SUPPORTED_VERSION"
CROSS_CXXFLAG="-mmacosx-version-min=$MACOS_MINIMUM_SUPPORTED_VERSION"
MACOS_FLAGS="-mmacosx-version-min=$MACOS_MINIMUM_SUPPORTED_VERSION"
CROSS_LDFLAG="$MACOS_FLAGS"
CROSS_CFLAG="$MACOS_FLAGS"
CROSS_CPPFLAG="$MACOS_FLAGS"
CROSS_CXXFLAG="$MACOS_FLAGS"
MAKE_JOBS="$(sysctl -n hw.ncpu)"
CMAKE_TOOLCHAIN_FILE=""
elif [ "$SCRIPT_ARCH" == "ios-arm64" ]; then
DEP_PREFIX="${DEP_PREFIX:-/work}"
mkdir -p "$DEP_PREFIX"
HOST_OPTION="--host=arm64-apple-darwin"
IOS_FLAGS="-miphoneos-version-min=$IOS_MINIMUM_SUPPORTED_VERSION -arch arm64 -isysroot $(xcrun --sdk iphoneos --show-sdk-path)"
CROSS_LDFLAG="$IOS_FLAGS"
CROSS_CFLAG="$IOS_FLAGS"
CROSS_CPPFLAG="$IOS_FLAGS"
CROSS_CXXFLAG="$IOS_FLAGS"
MAKE_JOBS="$(sysctl -n hw.ncpu)"
CMAKE_TOOLCHAIN_FILE=""
elif [[ "$SCRIPT_ARCH" == "linux"* ]]; then
Expand Down
13 changes: 11 additions & 2 deletions qtox/build_vpx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ readonly SCRIPT_DIR="$(dirname "$(realpath "$0")")"

source "$SCRIPT_DIR/build_utils.sh"

parse_arch --dep "vpx" --supported "linux-x86_64 win32 win64 macos-x86_64 macos-arm64" "$@"
parse_arch --dep "vpx" --supported "linux-aarch64 linux-x86_64 win32 win64 macos-x86_64 macos-arm64 ios-arm64" "$@"

if [ "$SCRIPT_ARCH" == "win64" ]; then
# There is a bug in gcc that breaks avx512 on 64-bit Windows https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54412
Expand All @@ -32,10 +32,18 @@ elif [ "$SCRIPT_ARCH" == "macos-arm64" ]; then
ARCH_FLAGS=""
CROSS_ARG=""
TARGET_ARG="arm64-darwin23-gcc" # macOS 14
elif [ "$SCRIPT_ARCH" == "ios-arm64" ]; then
ARCH_FLAGS=""
CROSS_ARG=""
TARGET_ARG="arm64-darwin-gcc"
elif [ "$SCRIPT_ARCH" == "linux-x86_64" ]; then
ARCH_FLAGS=""
CROSS_ARG=""
TARGET_ARG="x86_64-linux-gcc"
elif [ "$SCRIPT_ARCH" == "linux-aarch64" ]; then
ARCH_FLAGS=""
CROSS_ARG=""
TARGET_ARG="arm64-linux-gcc"
else
echo "Unsupported arch: $SCRIPT_ARCH"
exit 1
Expand Down Expand Up @@ -64,7 +72,8 @@ CFLAGS="-O2 $ARCH_FLAGS $CROSS_CFLAG" \
--disable-examples \
--disable-tools \
--disable-docs \
--disable-unit-tests
--disable-unit-tests \
--enable-pic

make -j "$MAKE_JOBS"
make install
Loading