Symbol tests for macos + whitelist imports/exports
All checks were successful
Tests / Clang total: 1096, passed: 1096
Clang |Total|New|Outstanding|Fixed|Trend
|:-:|:-:|:-:|:-:|:-:
|0|0|0|0|:clap:
Tests / SIMD fallback total: 1096, passed: 1096
Tests / Release [gcc] total: 1096, passed: 1096
GNU C Compiler (gcc) |Total|New|Outstanding|Fixed|Trend
|:-:|:-:|:-:|:-:|:-:
|0|0|0|0|:clap:
Tests / Release [gcc,aarch64] total: 824, passed: 824
Tests / Coverage total: 823, passed: 823
weaselab/conflict-set/pipeline/head This commit looks good
All checks were successful
Tests / Clang total: 1096, passed: 1096
Clang |Total|New|Outstanding|Fixed|Trend
|:-:|:-:|:-:|:-:|:-:
|0|0|0|0|:clap:
Tests / SIMD fallback total: 1096, passed: 1096
Tests / Release [gcc] total: 1096, passed: 1096
GNU C Compiler (gcc) |Total|New|Outstanding|Fixed|Trend
|:-:|:-:|:-:|:-:|:-:
|0|0|0|0|:clap:
Tests / Release [gcc,aarch64] total: 824, passed: 824
Tests / Coverage total: 823, passed: 823
weaselab/conflict-set/pipeline/head This commit looks good
commit1ad8276100
Author: Andrew Noyes <andrew@weaselab.dev> Date: Wed Apr 3 12:44:35 2024 -0700 Add symbols for arm build commit058e4d5302
Author: Andrew Noyes <andrew@weaselab.dev> Date: Wed Apr 3 12:42:48 2024 -0700 Add _GLOBAL_OFFSET_TABLE_ commita201f3ada8
Author: Andrew Noyes <andrew@weaselab.dev> Date: Wed Apr 3 12:34:05 2024 -0700 Add memset to symbol imports commitc1129ed0e2
Author: Andrew Noyes <andrew@weaselab.dev> Date: Wed Apr 3 12:32:28 2024 -0700 Add symbol imports file commit618766ce2e
Author: Andrew Noyes <andrew@weaselab.dev> Date: Wed Apr 3 12:27:07 2024 -0700 Fix objcopy filepath commite774a90007
Author: Andrew Noyes <andrew@weaselab.dev> Date: Wed Apr 3 12:24:44 2024 -0700 Use shellcheck precommit without docker commitbaddea7f57
Author: Andrew Noyes <andrew@weaselab.dev> Date: Wed Apr 3 12:20:26 2024 -0700 Update and freeze pre-commit hooks commit2d3e7b9004
Author: Andrew Noyes <andrew@weaselab.dev> Date: Wed Apr 3 12:19:55 2024 -0700 Add shellcheck to pre-commit Closes #22 commitc4862fee9b
Author: Andrew Noyes <andrew@weaselab.dev> Date: Wed Apr 3 12:15:08 2024 -0700 Add symbol tests for apple closes #21
This commit is contained in:
@@ -1,11 +1,11 @@
|
|||||||
repos:
|
repos:
|
||||||
- repo: https://github.com/pre-commit/mirrors-clang-format
|
- repo: https://github.com/pre-commit/mirrors-clang-format
|
||||||
rev: b111689e7b5cba60be3c62d5db2bd1357f4d36ca
|
rev: 6d365699efc33b1b432eab5b4ae331a19e1857de # frozen: v18.1.2
|
||||||
hooks:
|
hooks:
|
||||||
- id: clang-format
|
- id: clang-format
|
||||||
exclude: ".*third_party/.*"
|
exclude: ".*third_party/.*"
|
||||||
- repo: https://github.com/cheshirekow/cmake-format-precommit
|
- repo: https://github.com/cheshirekow/cmake-format-precommit
|
||||||
rev: e2c2116d86a80e72e7146a06e68b7c228afc6319
|
rev: e2c2116d86a80e72e7146a06e68b7c228afc6319 # frozen: v0.6.13
|
||||||
hooks:
|
hooks:
|
||||||
- id: cmake-format
|
- id: cmake-format
|
||||||
- repo: local
|
- repo: local
|
||||||
@@ -24,3 +24,7 @@ repos:
|
|||||||
entry: '^#define SHOW_MEMORY 1$'
|
entry: '^#define SHOW_MEMORY 1$'
|
||||||
language: pygrep
|
language: pygrep
|
||||||
types: [c++]
|
types: [c++]
|
||||||
|
- repo: https://github.com/shellcheck-py/shellcheck-py
|
||||||
|
rev: a23f6b85d0fdd5bb9d564e2579e678033debbdff # frozen: v0.10.0.1
|
||||||
|
hooks:
|
||||||
|
- id: shellcheck
|
@@ -136,7 +136,8 @@ else()
|
|||||||
TARGET ${PROJECT_NAME}-static
|
TARGET ${PROJECT_NAME}-static
|
||||||
POST_BUILD
|
POST_BUILD
|
||||||
COMMAND
|
COMMAND
|
||||||
${CMAKE_OBJCOPY} --keep-global-symbols=${CMAKE_SOURCE_DIR}/symbols.txt
|
${CMAKE_OBJCOPY}
|
||||||
|
--keep-global-symbols=${CMAKE_SOURCE_DIR}/symbol-exports.txt
|
||||||
$<TARGET_FILE:${PROJECT_NAME}-static> || echo
|
$<TARGET_FILE:${PROJECT_NAME}-static> || echo
|
||||||
"Proceeding with all symbols global in static library")
|
"Proceeding with all symbols global in static library")
|
||||||
endif()
|
endif()
|
||||||
@@ -295,18 +296,25 @@ if(BUILD_TESTING)
|
|||||||
add_test(NAME conflict_set_cxx_api_test COMMAND conflict_set_cxx_api_test)
|
add_test(NAME conflict_set_cxx_api_test COMMAND conflict_set_cxx_api_test)
|
||||||
|
|
||||||
# symbol visibility tests
|
# symbol visibility tests
|
||||||
if(NOT WASM
|
if(NOT WASM AND NOT CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||||
AND NOT APPLE
|
if(APPLE)
|
||||||
AND NOT CMAKE_BUILD_TYPE STREQUAL Debug)
|
set(symbol_exports ${CMAKE_SOURCE_DIR}/apple-symbol-exports.txt)
|
||||||
|
set(symbol_imports ${CMAKE_SOURCE_DIR}/apple-symbol-imports.txt)
|
||||||
|
else()
|
||||||
|
set(symbol_exports ${CMAKE_SOURCE_DIR}/symbol-exports.txt)
|
||||||
|
set(symbol_imports ${CMAKE_SOURCE_DIR}/symbol-imports.txt)
|
||||||
|
endif()
|
||||||
add_test(
|
add_test(
|
||||||
NAME conflict_set_shared_symbols
|
NAME conflict_set_shared_symbols
|
||||||
COMMAND ${CMAKE_SOURCE_DIR}/test_symbols.sh
|
COMMAND
|
||||||
$<TARGET_FILE:${PROJECT_NAME}> ${CMAKE_SOURCE_DIR}/symbols.txt)
|
${CMAKE_SOURCE_DIR}/test_symbols.sh $<TARGET_FILE:${PROJECT_NAME}>
|
||||||
|
${symbol_exports} ${symbol_imports})
|
||||||
add_test(
|
add_test(
|
||||||
NAME conflict_set_static_symbols
|
NAME conflict_set_static_symbols
|
||||||
COMMAND
|
COMMAND
|
||||||
${CMAKE_SOURCE_DIR}/test_symbols.sh
|
${CMAKE_SOURCE_DIR}/test_symbols.sh
|
||||||
$<TARGET_FILE:${PROJECT_NAME}-static> ${CMAKE_SOURCE_DIR}/symbols.txt)
|
$<TARGET_FILE:${PROJECT_NAME}-static> ${symbol_exports}
|
||||||
|
${symbol_imports})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# bench
|
# bench
|
||||||
|
@@ -2614,7 +2614,7 @@ int64_t ConflictSet::getBytes() const { return impl->totalBytes; }
|
|||||||
|
|
||||||
ConflictSet::ConflictSet(int64_t oldestVersion)
|
ConflictSet::ConflictSet(int64_t oldestVersion)
|
||||||
: impl((mallocBytesDelta = 0,
|
: impl((mallocBytesDelta = 0,
|
||||||
new (safe_malloc(sizeof(Impl))) Impl{oldestVersion})) {
|
new(safe_malloc(sizeof(Impl))) Impl{oldestVersion})) {
|
||||||
impl->totalBytes += mallocBytesDelta;
|
impl->totalBytes += mallocBytesDelta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -99,7 +99,7 @@ void ConflictSet::setOldestVersion(int64_t oldestVersion) {
|
|||||||
int64_t ConflictSet::getBytes() const { return -1; }
|
int64_t ConflictSet::getBytes() const { return -1; }
|
||||||
|
|
||||||
ConflictSet::ConflictSet(int64_t oldestVersion)
|
ConflictSet::ConflictSet(int64_t oldestVersion)
|
||||||
: impl(new (safe_malloc(sizeof(Impl))) Impl{oldestVersion}) {}
|
: impl(new(safe_malloc(sizeof(Impl))) Impl{oldestVersion}) {}
|
||||||
|
|
||||||
ConflictSet::~ConflictSet() {
|
ConflictSet::~ConflictSet() {
|
||||||
if (impl) {
|
if (impl) {
|
||||||
|
@@ -669,7 +669,7 @@ int64_t ConflictSet::getBytes() const { return impl->totalBytes; }
|
|||||||
|
|
||||||
ConflictSet::ConflictSet(int64_t oldestVersion)
|
ConflictSet::ConflictSet(int64_t oldestVersion)
|
||||||
: impl((mallocBytesDelta = 0,
|
: impl((mallocBytesDelta = 0,
|
||||||
new (safe_malloc(sizeof(Impl))) Impl{oldestVersion})) {
|
new(safe_malloc(sizeof(Impl))) Impl{oldestVersion})) {
|
||||||
impl->totalBytes += mallocBytesDelta;
|
impl->totalBytes += mallocBytesDelta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
17
apple-symbol-exports.txt
Normal file
17
apple-symbol-exports.txt
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
_ConflictSet_addWrites
|
||||||
|
_ConflictSet_check
|
||||||
|
_ConflictSet_create
|
||||||
|
_ConflictSet_destroy
|
||||||
|
_ConflictSet_getBytes
|
||||||
|
_ConflictSet_setOldestVersion
|
||||||
|
__ZN8weaselab11ConflictSet16setOldestVersionEx
|
||||||
|
__ZN8weaselab11ConflictSet9addWritesEPKNS0_10WriteRangeEix
|
||||||
|
__ZN8weaselab11ConflictSetC1EOS0_
|
||||||
|
__ZN8weaselab11ConflictSetC1Ex
|
||||||
|
__ZN8weaselab11ConflictSetC2EOS0_
|
||||||
|
__ZN8weaselab11ConflictSetC2Ex
|
||||||
|
__ZN8weaselab11ConflictSetD1Ev
|
||||||
|
__ZN8weaselab11ConflictSetD2Ev
|
||||||
|
__ZN8weaselab11ConflictSetaSEOS0_
|
||||||
|
__ZNK8weaselab11ConflictSet5checkEPKNS0_9ReadRangeEPNS0_6ResultEi
|
||||||
|
__ZNK8weaselab11ConflictSet8getBytesEv
|
7
apple-symbol-imports.txt
Normal file
7
apple-symbol-imports.txt
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
__tlv_bootstrap
|
||||||
|
_abort
|
||||||
|
_bzero
|
||||||
|
_free
|
||||||
|
_malloc
|
||||||
|
_memcpy
|
||||||
|
_memmove
|
@@ -2,5 +2,5 @@
|
|||||||
|
|
||||||
# This has the effect of making visibility=hidden symbols private in object files
|
# This has the effect of making visibility=hidden symbols private in object files
|
||||||
for obj in "$@" ; do
|
for obj in "$@" ; do
|
||||||
ld -r $obj -o $obj.tmp && mv $obj.tmp $obj
|
ld -r "$obj" -o "$obj.tmp" && mv "$obj.tmp" "$obj"
|
||||||
done
|
done
|
||||||
|
17
symbol-imports.txt
Normal file
17
symbol-imports.txt
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
_GLOBAL_OFFSET_TABLE_
|
||||||
|
__stack_chk_fail@GLIBC_2.17
|
||||||
|
__stack_chk_fail@GLIBC_2.4
|
||||||
|
__stack_chk_guard@GLIBC_2.17
|
||||||
|
__tls_get_addr@GLIBC_2.3
|
||||||
|
abort@GLIBC_2.17
|
||||||
|
abort@GLIBC_2.2.5
|
||||||
|
free@GLIBC_2.17
|
||||||
|
free@GLIBC_2.2.5
|
||||||
|
malloc@GLIBC_2.17
|
||||||
|
malloc@GLIBC_2.2.5
|
||||||
|
memcpy@GLIBC_2.14
|
||||||
|
memcpy@GLIBC_2.17
|
||||||
|
memmove@GLIBC_2.17
|
||||||
|
memmove@GLIBC_2.2.5
|
||||||
|
memset@GLIBC_2.17
|
||||||
|
memset@GLIBC_2.2.5
|
@@ -2,5 +2,15 @@
|
|||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
|
# ./test_symbols.sh <library> <expected exported symbols file> <allowed imported symbols file>
|
||||||
|
|
||||||
diff -u <(sort < "$2") <(nm "$1" | grep " T " | cut -f3 -d " " | sort)
|
diff -u <(sort < "$2") <(nm "$1" | grep " T " | cut -f3 -d " " | sort)
|
||||||
nm "$1" | grep " U " | (! grep -Pv 'abort|free|malloc|mem[a-z]*|__ashlti3|__stack_chk_[a-z]*|__tls_get_addr|_GLOBAL_OFFSET_TABLE_')
|
ec=0
|
||||||
|
for symbol in $(nm "$1" | grep " U " | sed 's/ U //') ; do
|
||||||
|
if ! grep --fixed-strings "$symbol" "$3" > /dev/null ; then
|
||||||
|
echo "Imported symbol $symbol not present in $3"
|
||||||
|
ec=1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
exit $ec
|
Reference in New Issue
Block a user