Skip to content

Commit f385bbb

Browse files
committed
fix: add explicit -fPIC to compiler flags (belt and suspenders with CMAKE_POSITION_INDEPENDENT_CODE)
1 parent 328911b commit f385bbb

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

patches/002-tls-model-dockerfile.patch

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ index 1111111..2222222 100644
77
ARG RELEASE_FLAGS="-O3 -DNDEBUG=1"
88
ARG LLVM_VERSION="19"
99
-ARG DEFAULT_CFLAGS="-mno-omit-leaf-frame-pointer -g -fno-omit-frame-pointer -ffunction-sections -fdata-sections -faddrsig -fno-unwind-tables -fno-asynchronous-unwind-tables -DU_STATIC_IMPLEMENTATION=1 "
10-
+# Added -ftls-model=global-dynamic for Node.js addon (dlopen) compatibility
11-
+ARG DEFAULT_CFLAGS="-mno-omit-leaf-frame-pointer -g -fno-omit-frame-pointer -ffunction-sections -fdata-sections -faddrsig -fno-unwind-tables -fno-asynchronous-unwind-tables -DU_STATIC_IMPLEMENTATION=1 -ftls-model=global-dynamic "
10+
+# Added -fPIC and -ftls-model=global-dynamic for Node.js addon (dlopen) compatibility
11+
+ARG DEFAULT_CFLAGS="-fPIC -mno-omit-leaf-frame-pointer -g -fno-omit-frame-pointer -ffunction-sections -fdata-sections -faddrsig -fno-unwind-tables -fno-asynchronous-unwind-tables -DU_STATIC_IMPLEMENTATION=1 -ftls-model=global-dynamic "
1212
ARG ENABLE_SANITIZERS=""
1313

1414
# Use different base images for ARM64 vs x86_64

patches/003-tls-model-dockerfile-musl.patch

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ index 1111111..2222222 100644
77
ARG LTO_FLAG="-flto=full -fwhole-program-vtables -fforce-emit-vtables "
88
ARG LLVM_VERSION="19"
99
-ARG DEFAULT_CFLAGS="-mno-omit-leaf-frame-pointer -g -fno-omit-frame-pointer -ffunction-sections -fdata-sections -faddrsig -fno-unwind-tables -fno-asynchronous-unwind-tables -DU_STATIC_IMPLEMENTATION=1 "
10-
+# Added -ftls-model=global-dynamic for Node.js addon (dlopen) compatibility
11-
+ARG DEFAULT_CFLAGS="-mno-omit-leaf-frame-pointer -g -fno-omit-frame-pointer -ffunction-sections -fdata-sections -faddrsig -fno-unwind-tables -fno-asynchronous-unwind-tables -DU_STATIC_IMPLEMENTATION=1 -ftls-model=global-dynamic "
10+
+# Added -fPIC and -ftls-model=global-dynamic for Node.js addon (dlopen) compatibility
11+
+ARG DEFAULT_CFLAGS="-fPIC -mno-omit-leaf-frame-pointer -g -fno-omit-frame-pointer -ffunction-sections -fdata-sections -faddrsig -fno-unwind-tables -fno-asynchronous-unwind-tables -DU_STATIC_IMPLEMENTATION=1 -ftls-model=global-dynamic "
1212

1313
FROM alpine:3.21 as base
1414

patches/004-tls-model-mac-release.patch

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ index 1111111..2222222 100644
77
THIS_DIR=$(pwd)
88

99
+# Added for Node.js addon (dlopen) compatibility
10+
+LIBBUN_PIC_FLAG="-fPIC"
1011
+LIBBUN_TLS_FLAG="-ftls-model=global-dynamic"
1112
+
1213
# Set default values for environment variables that are not set.
@@ -24,8 +25,8 @@ index 1111111..2222222 100644
2425
-DCMAKE_CXX_COMPILER="$CMAKE_CXX_COMPILER" \
2526
- -DCMAKE_C_FLAGS="-g $CMAKE_C_FLAGS -ffile-prefix-map=$THIS_DIR/Source=vendor/WebKit/Source" \
2627
- -DCMAKE_CXX_FLAGS="-g $CMAKE_CXX_FLAGS -ffile-prefix-map=$THIS_DIR/Source=vendor/WebKit/Source" \
27-
+ -DCMAKE_C_FLAGS="-g $CMAKE_C_FLAGS $LIBBUN_TLS_FLAG -ffile-prefix-map=$THIS_DIR/Source=vendor/WebKit/Source" \
28-
+ -DCMAKE_CXX_FLAGS="-g $CMAKE_CXX_FLAGS $LIBBUN_TLS_FLAG -ffile-prefix-map=$THIS_DIR/Source=vendor/WebKit/Source" \
28+
+ -DCMAKE_C_FLAGS="-g $CMAKE_C_FLAGS $LIBBUN_PIC_FLAG $LIBBUN_TLS_FLAG -ffile-prefix-map=$THIS_DIR/Source=vendor/WebKit/Source" \
29+
+ -DCMAKE_CXX_FLAGS="-g $CMAKE_CXX_FLAGS $LIBBUN_PIC_FLAG $LIBBUN_TLS_FLAG -ffile-prefix-map=$THIS_DIR/Source=vendor/WebKit/Source" \
2930
-DENABLE_MALLOC_HEAP_BREAKDOWN=$ENABLE_MALLOC_HEAP_BREAKDOWN \
3031
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
3132

0 commit comments

Comments
 (0)