[COMMIT seastar master] Merge 'build: build dpdk with `-fPIC` if BUILD_SHARED_LIBS' from Kefu Chai

46 views
Skip to first unread message

Commit Bot

<bot@cloudius-systems.com>
unread,
Feb 27, 2023, 8:13:39 AM2/27/23
to seastar-dev@googlegroups.com, Avi Kivity
From: Avi Kivity <a...@scylladb.com>
Committer: Avi Kivity <a...@scylladb.com>
Branch: master

Merge 'build: build dpdk with `-fPIC` if BUILD_SHARED_LIBS' from Kefu Chai

we should built the dependencies with -fPIC if Seastar is built as
a shared library.

before this change, dpdk is built without -fPIC, if it is built
with `cooking.sh`. and if user configures the building system with
debug or dev mode, seastar is compiled as a shared library. hence
the linker would fail to link libseastar with dpdk.

after this change, dpdk is compiled with `-fPIC`, so its symbols
are compiled as position-independent code, see
https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#index-fPIC .
so linker is able to link against it to build a shared library.

Fixes #1504
Signed-off-by: Kefu Chai <kefu...@scylladb.com>

Closes #1509

* github.com:scylladb/seastar:
build: build dpdk with `-fPIC` if BUILD_SHARED_LIBS
build: extract dpdk_extra_cflags out

---
diff --git a/cooking_recipe.cmake b/cooking_recipe.cmake
--- a/cooking_recipe.cmake
+++ b/cooking_recipe.cmake
@@ -280,9 +280,14 @@ else()
set (dpdk_quadruple ${CMAKE_SYSTEM_PROCESSOR}-native-linuxapp-gcc)
endif()

+# gcc 10 defaults to -fno-common, which dpdk is not prepared for
+set (dpdk_extra_cflags "-Wno-error -fcommon -fpie")
+if (BUILD_SHARED_LIBS)
+ string (APPEND dpdk_extra_cflags " -fPIC")
+endif ()
+
set (dpdk_args
- # gcc 10 defaults to -fno-common, which dpdk is not prepared for
- "EXTRA_CFLAGS=-Wno-error -fcommon -fpie"
+ "EXTRA_CFLAGS=${dpdk_extra_cflags}"
O=<BINARY_DIR>
DESTDIR=<INSTALL_DIR>
T=${dpdk_quadruple})
Reply all
Reply to author
Forward
0 new messages