-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Description
While packaging 1.14.1 for nixpkgs I noticed that Foundation/CMakeLists.txt:36 always includes some pcre source files, even when building a static library.
This causes these build errors:
poco> ld: warning: directory not found for option '-L/nix/store/cx5gh7gwhv06j4llivklbkfxyfgnk3sp-clang-19.1.7-lib/aarch64-apple-darwin/lib'
poco> duplicate symbol '__pcre2_utf8_table1_size' in:
poco> ../lib/libPocoFoundation.a(pcre2_tables.c.o)
poco> /nix/store/rji1qp342r9fgg5w2piivhgdzcbrj7vv-pcre2-static-aarch64-apple-darwin-10.44/lib/libpcre2-8.a(libpcre2_8_la-pcre2_tables.o)
poco> duplicate symbol '__pcre2_utt_8' in:
poco> ../lib/libPocoFoundation.a(pcre2_tables.c.o)
poco> /nix/store/rji1qp342r9fgg5w2piivhgdzcbrj7vv-pcre2-static-aarch64-apple-darwin-10.44/lib/libpcre2-8.a(libpcre2_8_la-pcre2_tables.o)
poco> duplicate symbol '__pcre2_vspace_list_8' in:
poco> ../lib/libPocoFoundation.a(pcre2_tables.c.o)
poco> /nix/store/rji1qp342r9fgg5w2piivhgdzcbrj7vv-pcre2-static-aarch64-apple-darwin-10.44/lib/libpcre2-8.a(libpcre2_8_la-pcre2_tables.o)
poco> duplicate symbol '__pcre2_hspace_list_8' in:
poco> ../lib/libPocoFoundation.a(pcre2_tables.c.o)
poco> /nix/store/rji1qp342r9fgg5w2piivhgdzcbrj7vv-pcre2-static-aarch64-apple-darwin-10.44/lib/libpcre2-8.a(libpcre2_8_la-pcre2_tables.o)
poco> duplicate symbol '__pcre2_callout_start_delims_8' in:
poco> ../lib/libPocoFoundation.a(pcre2_tables.c.o)
poco> /nix/store/rji1qp342r9fgg5w2piivhgdzcbrj7vv-pcre2-static-aarch64-apple-darwin-10.44/lib/libpcre2-8.a(libpcre2_8_la-pcre2_tables.o)
poco> duplicate symbol '__pcre2_callout_end_delims_8' in:
poco> ../lib/libPocoFoundation.a(pcre2_tables.c.o)
poco> /nix/store/rji1qp342r9fgg5w2piivhgdzcbrj7vv-pcre2-static-aarch64-apple-darwin-10.44/lib/libpcre2-8.a(libpcre2_8_la-pcre2_tables.o)
poco> duplicate symbol '__pcre2_OP_lengths_8' in:
poco> ../lib/libPocoFoundation.a(pcre2_tables.c.o)
poco> /nix/store/rji1qp342r9fgg5w2piivhgdzcbrj7vv-pcre2-static-aarch64-apple-darwin-10.44/lib/libpcre2-8.a(libpcre2_8_la-pcre2_tables.o)
poco> duplicate symbol '__pcre2_utt_names_8' in:
poco> ../lib/libPocoFoundation.a(pcre2_tables.c.o)
poco> /nix/store/rji1qp342r9fgg5w2piivhgdzcbrj7vv-pcre2-static-aarch64-apple-darwin-10.44/lib/libpcre2-8.a(libpcre2_8_la-pcre2_tables.o)
poco> duplicate symbol '__pcre2_utt_size_8' in:
poco> ../lib/libPocoFoundation.a(pcre2_tables.c.o)
poco> /nix/store/rji1qp342r9fgg5w2piivhgdzcbrj7vv-pcre2-static-aarch64-apple-darwin-10.44/lib/libpcre2-8.a(libpcre2_8_la-pcre2_tables.o)
poco> duplicate symbol '__pcre2_ucp_gentype_8' in:
poco> ../lib/libPocoFoundation.a(pcre2_tables.c.o)
poco> /nix/store/rji1qp342r9fgg5w2piivhgdzcbrj7vv-pcre2-static-aarch64-apple-darwin-10.44/lib/libpcre2-8.a(libpcre2_8_la-pcre2_tables.o)
poco> duplicate symbol '__pcre2_ucp_gbtable_8' in:
poco> ../lib/libPocoFoundation.a(pcre2_tables.c.o)
poco> /nix/store/rji1qp342r9fgg5w2piivhgdzcbrj7vv-pcre2-static-aarch64-apple-darwin-10.44/lib/libpcre2-8.a(libpcre2_8_la-pcre2_tables.o)
poco> duplicate symbol '__pcre2_utf8_table4' in:
poco> ../lib/libPocoFoundation.a(pcre2_tables.c.o)
poco> /nix/store/rji1qp342r9fgg5w2piivhgdzcbrj7vv-pcre2-static-aarch64-apple-darwin-10.44/lib/libpcre2-8.a(libpcre2_8_la-pcre2_tables.o)
poco> duplicate symbol '__pcre2_utf8_table3' in:
poco> ../lib/libPocoFoundation.a(pcre2_tables.c.o)
poco> /nix/store/rji1qp342r9fgg5w2piivhgdzcbrj7vv-pcre2-static-aarch64-apple-darwin-10.44/lib/libpcre2-8.a(libpcre2_8_la-pcre2_tables.o)
poco> duplicate symbol '__pcre2_utf8_table2' in:
poco> ../lib/libPocoFoundation.a(pcre2_tables.c.o)
poco> /nix/store/rji1qp342r9fgg5w2piivhgdzcbrj7vv-pcre2-static-aarch64-apple-darwin-10.44/lib/libpcre2-8.a(libpcre2_8_la-pcre2_tables.o)
poco> duplicate symbol '__pcre2_utf8_table1' in:
poco> ../lib/libPocoFoundation.a(pcre2_tables.c.o)
poco> /nix/store/rji1qp342r9fgg5w2piivhgdzcbrj7vv-pcre2-static-aarch64-apple-darwin-10.44/lib/libpcre2-8.a(libpcre2_8_la-pcre2_tables.o)
poco> ld: 15 duplicate symbols for architecture arm64
(Same error message but different formulation on linux).
There are also several open bugs in this tracker about failing static builds, which might be caused by the same issue.
I have worked around this issue by using this patch:
diff --git a/Foundation/CMakeLists.txt b/Foundation/CMakeLists.txt
index d5f3b267d..dfaf99a10 100644
--- a/Foundation/CMakeLists.txt
+++ b/Foundation/CMakeLists.txt
@@ -31,11 +31,13 @@ if(POCO_UNBUNDLED)
find_package(ZLIB REQUIRED)
find_package(Utf8Proc REQUIRED)
- #HACK: Unicode.cpp requires functions from these files. The can't be taken from the library
- POCO_SOURCES(SRCS RegExp
- src/pcre2_ucd.c
- src/pcre2_tables.c
- )
+ if(NOT POCO_STATIC AND BUILD_SHARED_LIBS)
+ #HACK: Unicode.cpp requires functions from these files. The can't be taken from the library
+ POCO_SOURCES(SRCS RegExp
+ src/pcre2_ucd.c
+ src/pcre2_tables.c
+ )
+ endif()
else()
# pcre2
However, I am not very fluent in cmake, so I am not sure if this condition is correct for the poco build. I have seen in the changelog that falling back to BUILD_SHARED_LIBS
was used in other places, and since this is what nix sets by default when doing a static build I included it, but as I said I'm not sure. :)
What do you think? Would you include this in poco upstream for the next release?