Skip to content

Commit ff8337a

Browse files
committed
Push some changes from last week
1 parent 08529db commit ff8337a

14 files changed

+342
-299
lines changed

.github/workflows/dev.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -397,16 +397,17 @@ jobs:
397397
githubToken: ${{ github.token }}
398398

399399
env: | # YAML, but pipe character is necessary
400-
CFLAGS_GCC_STYLE: ${{ env.CFLAGS_GCC_STYLE }}
400+
# -Wmaybe-uninitialized is spammy. It's not a useful warning for
401+
# these multiarch builds.
402+
CFLAGS_GCC_STYLE: ${{ env.CFLAGS_GCC_STYLE }} -Wno-maybe-uninitialized
401403
402404
install: |
403405
apt-get -qq update
404406
apt-get -qq install -y gcc cmake ninja-build zlib1g-dev libbz2-dev
405407
406408
run: |
407409
set -e
408-
# TODO: Set -DCMAKE_COMPILE_WARNING_AS_ERROR=ON (there's currently a build failure on S390x)
409-
cmake -G Ninja -DPCRE2_SUPPORT_JIT=ON -DPCRE2_BUILD_PCRE2_16=ON -DPCRE2_BUILD_PCRE2_32=ON -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=ON -DPCRE2_DEBUG=ON -DCMAKE_C_FLAGS="$CFLAGS_GCC_STYLE" -DCMAKE_COMPILE_WARNING_AS_ERROR=OFF -DCMAKE_BUILD_TYPE=RelWithDebInfo -B build
410+
cmake -G Ninja -DPCRE2_SUPPORT_JIT=ON -DPCRE2_BUILD_PCRE2_16=ON -DPCRE2_BUILD_PCRE2_32=ON -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=ON -DPCRE2_DEBUG=ON -DCMAKE_C_FLAGS="$CFLAGS_GCC_STYLE" -DCMAKE_COMPILE_WARNING_AS_ERROR=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo -B build
410411
ninja -C build
411412
(cd build && ctest -j3 --output-on-failure)
412413

CMakeLists.txt

Lines changed: 53 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,12 @@ check_c_source_compiles(
204204
HAVE_VISIBILITY
205205
)
206206

207+
if(HAVE_VISIBILITY)
208+
set(PCRE2_EXPORT [=[__attribute__ ((visibility ("default")))]=])
209+
else()
210+
set(PCRE2_EXPORT)
211+
endif()
212+
207213
set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
208214

209215
check_c_source_compiles("int main(void) { __assume(1); return 0; }" HAVE_BUILTIN_ASSUME)
@@ -221,11 +227,33 @@ check_c_source_compiles(
221227
HAVE_BUILTIN_UNREACHABLE
222228
)
223229

224-
if(HAVE_VISIBILITY)
225-
set(PCRE2_EXPORT [=[__attribute__ ((visibility ("default")))]=])
226-
else()
227-
set(PCRE2_EXPORT)
230+
# Detect support for linker scripts.
231+
232+
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/test-map-file.sym "PCRE2_10.00 { global: main; };")
233+
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/test-map-file-broken.sym "PCRE2_10.00 { global: main; }; {")
234+
pcre2_check_linker_flag(C -Wl,--version-script,${CMAKE_CURRENT_BINARY_DIR}/test-map-file.sym HAVE_VSCRIPT_GNU)
235+
pcre2_check_linker_flag(C -Wl,-M,${CMAKE_CURRENT_BINARY_DIR}/test-map-file.sym HAVE_VSCRIPT_SUN)
236+
if(HAVE_VSCRIPT_GNU)
237+
set(VSCRIPT_FLAG --version-script)
238+
set(HAVE_VSCRIPT TRUE)
239+
elseif(HAVE_VSCRIPT_SUN)
240+
set(VSCRIPT_FLAG -M)
241+
set(HAVE_VSCRIPT TRUE)
228242
endif()
243+
if(HAVE_VSCRIPT)
244+
# Perform the same logic as ax_check_vscript.m4, to test whether the linker
245+
# silently ignores (and overwrites) linker scripts it doesn't understand.
246+
pcre2_check_linker_flag(
247+
C
248+
-Wl,${VSCRIPT_FLAG},${CMAKE_CURRENT_BINARY_DIR}/test-map-file-broken.sym
249+
HAVE_VSCRIPT_BROKEN
250+
)
251+
if(HAVE_VSCRIPT_BROKEN)
252+
set(HAVE_VSCRIPT FALSE)
253+
endif()
254+
endif()
255+
file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/test-map-file.sym)
256+
file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/test-map-file-broken.sym)
229257

230258
# Check whether Intel CET is enabled, and if so, adjust compiler flags. This
231259
# code was written by PH, trying to imitate the logic from the autotools
@@ -397,6 +425,10 @@ if(MSVC)
397425
option(INSTALL_MSVC_PDB "ON=Install .pdb files built by MSVC, if generated" OFF)
398426
endif()
399427

428+
if(HAVE_VSCRIPT)
429+
option(PCRE2_SYMVERS "Enable library symbol versioning" ON)
430+
endif()
431+
400432
# bzip2 lib
401433
if(BZIP2_FOUND)
402434
option(PCRE2_SUPPORT_LIBBZ2 "Enable support for linking pcre2grep with libbz2." ON)
@@ -630,34 +662,6 @@ if(EBCDIC)
630662
endif()
631663
endif()
632664

633-
# Detect support for linker scripts.
634-
635-
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/test-map-file.sym "PCRE2_10.00 { global: main; };")
636-
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/test-map-file-broken.sym "PCRE2_10.00 { global: main; }; {")
637-
pcre2_check_linker_flag(C -Wl,--version-script,${CMAKE_CURRENT_BINARY_DIR}/test-map-file.sym HAVE_VSCRIPT_GNU)
638-
pcre2_check_linker_flag(C -Wl,-M,${CMAKE_CURRENT_BINARY_DIR}/test-map-file.sym HAVE_VSCRIPT_SUN)
639-
if(HAVE_VSCRIPT_GNU)
640-
set(VSCRIPT_FLAG --version-script)
641-
set(HAVE_VSCRIPT TRUE)
642-
elseif(HAVE_VSCRIPT_SUN)
643-
set(VSCRIPT_FLAG -M)
644-
set(HAVE_VSCRIPT TRUE)
645-
endif()
646-
if(HAVE_VSCRIPT)
647-
# Perform the same logic as ax_check_vscript.m4, to test whether the linker
648-
# silently ignores (and overwrites) linker scripts it doesn't understand.
649-
pcre2_check_linker_flag(
650-
C
651-
-Wl,${VSCRIPT_FLAG},${CMAKE_CURRENT_BINARY_DIR}/test-map-file-broken.sym
652-
HAVE_VSCRIPT_BROKEN
653-
)
654-
if(HAVE_VSCRIPT_BROKEN)
655-
set(HAVE_VSCRIPT FALSE)
656-
endif()
657-
endif()
658-
file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/test-map-file.sym)
659-
file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/test-map-file-broken.sym)
660-
661665
# Output files
662666

663667
configure_file(src/config-cmake.h.in ${PROJECT_BINARY_DIR}/config.h @ONLY)
@@ -927,7 +931,7 @@ if(PCRE2_BUILD_PCRE2_8)
927931
if(REQUIRE_PTHREAD)
928932
target_link_libraries(pcre2-8-shared Threads::Threads)
929933
endif()
930-
if(HAVE_VSCRIPT)
934+
if(HAVE_VSCRIPT AND PCRE2_SYMVERS)
931935
target_link_options(pcre2-8-shared PRIVATE -Wl,${VSCRIPT_FLAG},${PROJECT_SOURCE_DIR}/src/libpcre2-8.sym)
932936
set_target_properties(pcre2-8-shared PROPERTIES LINK_DEPENDS ${PROJECT_SOURCE_DIR}/src/libpcre2-8.sym)
933937
endif()
@@ -947,7 +951,7 @@ if(PCRE2_BUILD_PCRE2_8)
947951
SOVERSION ${LIBPCRE2_POSIX_SOVERSION}
948952
OUTPUT_NAME pcre2-posix
949953
)
950-
if(HAVE_VSCRIPT)
954+
if(HAVE_VSCRIPT AND PCRE2_SYMVERS)
951955
target_link_options(pcre2-posix-shared PRIVATE -Wl,${VSCRIPT_FLAG},${PROJECT_SOURCE_DIR}/src/libpcre2-posix.sym)
952956
set_target_properties(pcre2-posix-shared PROPERTIES LINK_DEPENDS ${PROJECT_SOURCE_DIR}/src/libpcre2-posix.sym)
953957
endif()
@@ -1024,7 +1028,7 @@ if(PCRE2_BUILD_PCRE2_16)
10241028
if(REQUIRE_PTHREAD)
10251029
target_link_libraries(pcre2-16-shared Threads::Threads)
10261030
endif()
1027-
if(HAVE_VSCRIPT)
1031+
if(HAVE_VSCRIPT AND PCRE2_SYMVERS)
10281032
target_link_options(pcre2-16-shared PRIVATE -Wl,${VSCRIPT_FLAG},${PROJECT_SOURCE_DIR}/src/libpcre2-16.sym)
10291033
set_target_properties(pcre2-16-shared PROPERTIES LINK_DEPENDS ${PROJECT_SOURCE_DIR}/src/libpcre2-16.sym)
10301034
endif()
@@ -1096,7 +1100,7 @@ if(PCRE2_BUILD_PCRE2_32)
10961100
if(REQUIRE_PTHREAD)
10971101
target_link_libraries(pcre2-32-shared Threads::Threads)
10981102
endif()
1099-
if(HAVE_VSCRIPT)
1103+
if(HAVE_VSCRIPT AND PCRE2_SYMVERS)
11001104
target_link_options(pcre2-32-shared PRIVATE -Wl,${VSCRIPT_FLAG},${PROJECT_SOURCE_DIR}/src/libpcre2-32.sym)
11011105
set_target_properties(pcre2-32-shared PROPERTIES LINK_DEPENDS ${PROJECT_SOURCE_DIR}/src/libpcre2-32.sym)
11021106
endif()
@@ -1433,9 +1437,9 @@ if(PCRE2_SHOW_REPORT)
14331437
else()
14341438
message(STATUS " Build type ........................ : ${CMAKE_BUILD_TYPE}")
14351439
endif()
1436-
message(STATUS " Build 8 bit PCRE2 library ......... : ${PCRE2_BUILD_PCRE2_8}")
1437-
message(STATUS " Build 16 bit PCRE2 library ........ : ${PCRE2_BUILD_PCRE2_16}")
1438-
message(STATUS " Build 32 bit PCRE2 library ........ : ${PCRE2_BUILD_PCRE2_32}")
1440+
message(STATUS " Build 8 bit pcre2 library ......... : ${PCRE2_BUILD_PCRE2_8}")
1441+
message(STATUS " Build 16 bit pcre2 library ........ : ${PCRE2_BUILD_PCRE2_16}")
1442+
message(STATUS " Build 32 bit pcre2 library ........ : ${PCRE2_BUILD_PCRE2_32}")
14391443
message(STATUS " Include debugging code ............ : ${PCRE2_DEBUG}")
14401444
message(STATUS " Enable JIT compiling support ...... : ${PCRE2_SUPPORT_JIT}")
14411445
message(STATUS " Use SELinux allocator in JIT ...... : ${PCRE2_SUPPORT_JIT_SEALLOC}")
@@ -1458,18 +1462,24 @@ if(PCRE2_SHOW_REPORT)
14581462

14591463
message(STATUS " Internal link size ................ : ${PCRE2_LINK_SIZE}")
14601464
message(STATUS " Maximum variable lookbehind ....... : ${PCRE2_MAX_VARLOOKBEHIND}")
1461-
message(STATUS " Parentheses nest limit ............ : ${PCRE2_PARENS_NEST_LIMIT}")
1465+
message(STATUS " Nested parentheses limit .......... : ${PCRE2_PARENS_NEST_LIMIT}")
14621466
message(STATUS " Heap limit ........................ : ${PCRE2_HEAP_LIMIT}")
14631467
message(STATUS " Match limit ....................... : ${PCRE2_MATCH_LIMIT}")
14641468
message(STATUS " Match depth limit ................. : ${PCRE2_MATCH_LIMIT_DEPTH}")
14651469
message(STATUS " Build shared libs ................. : ${BUILD_SHARED_LIBS}")
1470+
if(NOT HAVE_VSCRIPT)
1471+
message(STATUS " with symbol versioning ........ : n/a")
1472+
else()
1473+
message(STATUS " with symbol versioning ........ : ${PCRE2_SYMVERS}")
1474+
endif()
14661475
message(STATUS " Build static libs ................. : ${BUILD_STATIC_LIBS}")
1467-
message(STATUS " with PIC enabled ............... : ${PCRE2_STATIC_PIC}")
1476+
message(STATUS " with PIC enabled .............. : ${PCRE2_STATIC_PIC}")
14681477
message(STATUS " Build pcre2grep ................... : ${PCRE2_BUILD_PCRE2GREP}")
14691478
message(STATUS " Enable JIT in pcre2grep ........... : ${PCRE2GREP_SUPPORT_JIT}")
14701479
message(STATUS " Enable callouts in pcre2grep ...... : ${PCRE2GREP_SUPPORT_CALLOUT}")
14711480
message(STATUS " Enable callout fork in pcre2grep .. : ${PCRE2GREP_SUPPORT_CALLOUT_FORK}")
1472-
message(STATUS " Buffer size for pcre2grep ......... : ${PCRE2GREP_BUFSIZE}")
1481+
message(STATUS " Initial buffer size for pcre2grep . : ${PCRE2GREP_BUFSIZE}")
1482+
message(STATUS " Maximum buffer size for pcre2grep . : ${PCRE2GREP_MAX_BUFSIZE}")
14731483
message(STATUS " Build tests (implies pcre2test .... : ${PCRE2_BUILD_TESTS}")
14741484
message(STATUS " and pcre2grep)")
14751485
if(ZLIB_FOUND)
@@ -1492,7 +1502,7 @@ if(PCRE2_SHOW_REPORT)
14921502
else()
14931503
message(STATUS " Link pcre2test with libreadline ... : Library not found")
14941504
endif()
1495-
message(STATUS " Support Valgrind .................. : ${PCRE2_SUPPORT_VALGRIND}")
1505+
message(STATUS " Enable Valgrind support ........... : ${PCRE2_SUPPORT_VALGRIND}")
14961506
if(PCRE2_DISABLE_PERCENT_ZT)
14971507
message(STATUS " Use %zu and %td ................... : OFF")
14981508
else()

configure.ac

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,6 +1233,13 @@ elif test "$enable_ebcdic" = "yes"; then
12331233
ebcdic_nl_code=0x15
12341234
fi
12351235

1236+
with_symbol_versioning=n/a
1237+
if test x$want_symvers != xyes; then
1238+
with_symbol_versioning=no
1239+
elif test x$ax_check_vscript_flag != x; then
1240+
with_symbol_versioning=yes
1241+
fi
1242+
12361243
cat <<EOF
12371244

12381245
$PACKAGE-$VERSION configuration summary:
@@ -1267,8 +1274,9 @@ $PACKAGE-$VERSION configuration summary:
12671274
Match limit ........................ : ${with_match_limit}
12681275
Match depth limit .................. : ${with_match_limit_depth}
12691276
Build shared libs .................. : ${enable_shared}
1277+
with symbol versioning ......... : ${with_symbol_versioning}
12701278
Build static libs .................. : ${enable_static}
1271-
Use JIT in pcre2grep ............... : ${enable_pcre2grep_jit}
1279+
Enable JIT in pcre2grep ............ : ${enable_pcre2grep_jit}
12721280
Enable callouts in pcre2grep ....... : ${enable_pcre2grep_callout}
12731281
Enable fork in pcre2grep callouts .. : ${enable_pcre2grep_callout_fork}
12741282
Initial buffer size for pcre2grep .. : ${with_pcre2grep_bufsize}
@@ -1277,7 +1285,7 @@ $PACKAGE-$VERSION configuration summary:
12771285
Link pcre2grep with libbz2 ......... : ${enable_pcre2grep_libbz2}
12781286
Link pcre2test with libedit ........ : ${enable_pcre2test_libedit}
12791287
Link pcre2test with libreadline .... : ${enable_pcre2test_libreadline}
1280-
Valgrind support ................... : ${enable_valgrind}
1288+
Enable Valgrind support ............ : ${enable_valgrind}
12811289
Code coverage ...................... : ${enable_coverage}
12821290
Fuzzer support ..................... : ${enable_fuzz_support}
12831291
Differential fuzzer support ........ : ${enable_diff_fuzz_support}

maint/RunManifestTest

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ LANG=C # Ensure stable ordering of `sort` output
99
export LANG
1010

1111
if [ "$1" = "" -o "$2" = "" ] ; then
12-
echo "Usage: $0 <dir> <manifest name>" >&2
12+
echo "Usage: $0 <dir> <manifest name>" >&2
1313
exit 1
1414
fi
1515

@@ -32,11 +32,11 @@ find "$input_dir" -print | \
3232
> "$base"
3333

3434
if ! diff -u "$expected_manifest" "$base"; then
35-
echo "Installed files differ from expected" >&2
35+
echo "Installed files differ from expected"
3636

37-
echo "===Actual===" >&2
38-
cat "$base" >&2
39-
echo "===End===" >&2
37+
echo "===Actual==="
38+
cat "$base"
39+
echo "===End==="
4040

4141
exit 1
4242
fi

maint/RunSymbolTest

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ LANG=C # Ensure stable ordering of `sort` output
88
export LANG
99

1010
if [ "$1" = "" -o "$2" = "" ] ; then
11-
echo "Usage: $0 <so_dir> <manifest_dir>" >&2
11+
echo "Usage: $0 <so_dir> <manifest_dir>" >&2
1212
exit 1
1313
fi
1414

@@ -26,12 +26,19 @@ if [ -f /usr/bin/ggrep ] ; then
2626
fi
2727

2828
nm="nm -B -D"
29+
if [ "`uname -s`" = "Linux" ]; then
30+
nm="$nm --with-symbol-versions"
2931
if [ "`uname -s`" = "SunOS" ]; then
3032
nm="nm -p -h -D -g"
3133
elif [ "`uname -s`" = "Darwin" ]; then
3234
nm="nm -B -g"
3335
fi
3436

37+
supports_versions=1
38+
if [ "`uname -s`" = "Darwin" ]; then
39+
supports_versions=0
40+
fi
41+
3542
so_ext=so
3643
so_mangling() { cat; }
3744
if [ "`uname -s`" = "Darwin" ]; then
@@ -50,23 +57,31 @@ for so_name in "libpcre2-8" "libpcre2-16" "libpcre2-32" "libpcre2-posix"; do
5057
$nm "$so_file" | \
5158
$sed -E -e 's/^[0-9a-fA-F]* *//g' | \
5259
$grep -E -v '^[Uw] ' | \
60+
$grep -E -v '^A PCRE2_' | \
5361
$grep -E -v ' (_init|_fini)$' | \
5462
$grep -E -v ' (_end|_DYNAMIC|_GLOBAL_OFFSET_TABLE_|_PROCEDURE_LINKAGE_TABLE_|_edata|_etext)$' | \
5563
so_mangling | \
5664
sort \
57-
> "$base"
65+
> "$base.actual"
66+
67+
if [ $supports_versions -eq 0 ]; then
68+
$sed -E -e 's/@.*$//' "$expected_file" \
69+
> "$base.expected"
70+
else
71+
cp "$expected_file" "$base.expected"
72+
fi
5873

59-
if ! diff -u "$expected_file" "$base"; then
60-
echo "Shared object contents for $so_file differ from expected" >&2
74+
if ! diff -u "$base.expected" "$base.actual"; then
75+
echo "Shared object contents for $so_file differ from expected"
6176

62-
echo "===Actual===" >&2
63-
cat "$base" >&2
64-
echo "===End===" >&2
77+
echo "===Actual==="
78+
cat "$base.actual"
79+
echo "===End==="
6580

6681
exit 1
6782
fi
6883

6984
echo "Shared object contents for $so_file match expected"
70-
rm -f "$base"
85+
rm -f "$base.expected" "$base.actual"
7186

7287
done

0 commit comments

Comments
 (0)