Skip to content

Commit dfdcc50

Browse files
committed
update to vendored version
1 parent 2f6bf23 commit dfdcc50

18 files changed

Lines changed: 1696 additions & 22 deletions

‎CMakeLists.txt‎

Lines changed: 65 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,33 @@ endif()
7878
# Compiler Flags
7979
# ============================================================================
8080

81-
# Enable ASAN/UBSAN in Debug builds (Generic)
81+
# Enable ASAN/UBSAN in Debug builds (Generic).
82+
#
83+
# When built standalone, default to ASan+UBSan. When built as part of a parent
84+
# project that defines USE_MEM_SANITIZERS/USE_THREAD_SANITIZERS, defer entirely
85+
# to the parent's choice: the parent already added the right -fsanitize=... flags
86+
# to CMAKE_C_FLAGS_DEBUG (which apply here too), and ASan/LeakSan cannot be linked
87+
# into the same binary as TSan, so this library must never add its own ASan flags
88+
# on top of a parent-selected TSan build.
89+
set(YAFL_ASAN_ACTIVE FALSE)
90+
set(YAFL_TSAN_ACTIVE FALSE)
91+
8292
if(CMAKE_BUILD_TYPE STREQUAL "Debug" AND NOT MSVC)
83-
message(STATUS "Debug build detected: Enabling ASAN/UBSAN")
84-
add_compile_options($<$<COMPILE_LANGUAGE:C>:-fsanitize=address,undefined>)
85-
add_compile_options($<$<COMPILE_LANGUAGE:C>:-fno-omit-frame-pointer>)
86-
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address,undefined")
93+
if(DEFINED USE_MEM_SANITIZERS OR DEFINED USE_THREAD_SANITIZERS)
94+
if(USE_THREAD_SANITIZERS)
95+
message(STATUS "Debug build detected: using parent-selected ThreadSanitizer")
96+
set(YAFL_TSAN_ACTIVE TRUE)
97+
elseif(USE_MEM_SANITIZERS)
98+
message(STATUS "Debug build detected: using parent-selected ASAN/UBSAN")
99+
set(YAFL_ASAN_ACTIVE TRUE)
100+
endif()
101+
else()
102+
message(STATUS "Debug build detected: Enabling ASAN/UBSAN")
103+
add_compile_options($<$<COMPILE_LANGUAGE:C>:-fsanitize=address,undefined>)
104+
add_compile_options($<$<COMPILE_LANGUAGE:C>:-fno-omit-frame-pointer>)
105+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address,undefined")
106+
set(YAFL_ASAN_ACTIVE TRUE)
107+
endif()
87108

88109
# Automatically enable watermark checking in debug builds
89110
message(STATUS "Enabling stack watermark for Debug build")
@@ -130,6 +151,10 @@ else()
130151
set(HOST_ARCH "x86_64")
131152
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "arm64|aarch64|ARM64|AARCH64")
132153
set(HOST_ARCH "aarch64")
154+
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm|^ARM")
155+
set(HOST_ARCH "arm")
156+
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^x86$|^i386$|^i686$|^Win32$")
157+
set(HOST_ARCH "i386")
133158
else()
134159
message(FATAL_ERROR "Could not auto-detect architecture. Please specify -DTARGET=<triple>")
135160
endif()
@@ -184,6 +209,20 @@ endif()
184209

185210
if(CMAKE_SYSTEM_NAME STREQUAL "iOS" OR CMAKE_SYSTEM_NAME STREQUAL "Android")
186211
message(STATUS "Skipping stack direction check for ${CMAKE_SYSTEM_NAME} (assuming downward)")
212+
elseif(YAFL_ASAN_ACTIVE)
213+
# Under ASan, this probe is unreliable: ASan's stack-use-after-return "fake stack"
214+
# can allocate a function's locals off the real machine stack entirely, so comparing
215+
# caller/callee frame addresses no longer reflects true hardware stack growth
216+
# direction. Skip the runtime probe and rely on the well-known fact that every
217+
# architecture this project ships a toolchain/asm implementation for grows downward.
218+
message(STATUS "Skipping stack direction check under ASan/UBSan (assuming downward)")
219+
elseif(CMAKE_CROSSCOMPILING AND CMAKE_CROSSCOMPILING_EMULATOR MATCHES "qemu")
220+
# ponytail: QEMU user-mode emulation (e.g. the s390x CI leg) has been observed to make
221+
# this probe report "upward" on architectures that are well-documented to grow the
222+
# stack downward under their native SysV/Linux ABI (s390x included) and for which this
223+
# project already ships a hand-verified downward-stack asm implementation (gated by the
224+
# toolchains/${TRIPLE}.cmake lookup above). Trust the ABI instead of an emulator-only probe.
225+
message(STATUS "Skipping stack direction check under QEMU user-mode emulation (assuming downward per target ABI)")
187226
elseif(NOT CMAKE_CROSSCOMPILING OR CMAKE_CROSSCOMPILING_EMULATOR)
188227
message(STATUS "Checking stack direction...")
189228
try_run(STACK_DIR_EXITCODE STACK_DIR_COMPILED
@@ -192,7 +231,11 @@ elseif(NOT CMAKE_CROSSCOMPILING OR CMAKE_CROSSCOMPILING_EMULATOR)
192231
)
193232

194233
if(STACK_DIR_COMPILED)
195-
if(STACK_DIR_EXITCODE EQUAL 0)
234+
if(STACK_DIR_EXITCODE STREQUAL "FAILED_TO_RUN")
235+
# ponytail: sandboxed/CI environments can deny exec of the freshly-built probe
236+
# even when not cross-compiling. That's "couldn't test it", not "tested upward".
237+
message(WARNING "Could not execute stack direction check (sandboxed environment?). Assuming downward stack.")
238+
elseif(STACK_DIR_EXITCODE EQUAL 0)
196239
message(STATUS "Stack grows downward (supported)")
197240
else()
198241
message(FATAL_ERROR "Stack grows upward! This architecture is not supported by yafl.")
@@ -205,9 +248,22 @@ else()
205248
endif()
206249

207250
# ============================================================================
208-
# Test Executables
251+
# Library
209252
# ============================================================================
210253

254+
# Create static library
255+
add_library(yafl STATIC src/yafl.c ${ASM_FILES})
256+
target_include_directories(yafl PUBLIC include)
257+
set_target_properties(yafl PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR})
258+
259+
# ============================================================================
260+
# Test Executables (Debug builds only)
261+
# ============================================================================
262+
263+
# Gate tests to Debug builds: assert()-heavy test code produces -Wunused-variable
264+
# errors under -Werror in optimized builds where NDEBUG is defined.
265+
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
266+
211267
set(TESTS
212268
test_yafl_basic
213269
test_yafl_suspend_resume
@@ -216,11 +272,6 @@ set(TESTS
216272
test_yafl_watermark
217273
)
218274

219-
# Create static library
220-
add_library(yafl STATIC src/yafl.c ${ASM_FILES})
221-
target_include_directories(yafl PUBLIC include)
222-
set_target_properties(yafl PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR})
223-
224275
foreach(test ${TESTS})
225276
add_executable(${test} tests/${test}.c)
226277
target_link_libraries(${test} PRIVATE yafl)
@@ -247,6 +298,8 @@ endforeach()
247298
# test_yafl_guard is expected to crash (segfault) due to stack overflow
248299
# set_tests_properties(test_yafl_guard PROPERTIES WILL_FAIL TRUE)
249300

301+
endif() # CMAKE_BUILD_TYPE STREQUAL "Debug"
302+
250303
# ============================================================================
251304
# Summary
252305
# ============================================================================

‎build-tsan/DartConfiguration.tcl‎

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
# This file is configured by CMake automatically as DartConfiguration.tcl
2+
# If you choose not to use CMake, this file may be hand configured, by
3+
# filling in the required variables.
4+
5+
6+
# Configuration directories and files
7+
SourceDirectory: /Users/kyle/Projects/yafl
8+
BuildDirectory: /Users/kyle/Projects/yafl/build-tsan
9+
10+
# Where to place the cost data store
11+
CostDataFile:
12+
13+
# Site is something like machine.domain, i.e. pragmatic.crd
14+
Site: Kyles-MacBook-Air.local
15+
16+
# Build name is osname-revision-compiler, i.e. Linux-2.4.2-2smp-c++
17+
BuildName: Darwin-cc
18+
19+
# Subprojects
20+
LabelsForSubprojects:
21+
22+
# Submission information
23+
SubmitURL: http://
24+
SubmitInactivityTimeout:
25+
26+
# Dashboard start time
27+
NightlyStartTime: 00:00:00 EDT
28+
29+
# Commands for the build/test/submit cycle
30+
ConfigureCommand: "/opt/homebrew/bin/cmake" "/Users/kyle/Projects/yafl"
31+
MakeCommand: /opt/homebrew/bin/cmake --build . --config "${CTEST_CONFIGURATION_TYPE}"
32+
DefaultCTestConfigurationType: Release
33+
34+
# version control
35+
UpdateVersionOnly:
36+
37+
# CVS options
38+
# Default is "-d -P -A"
39+
CVSCommand:
40+
CVSUpdateOptions:
41+
42+
# Subversion options
43+
SVNCommand:
44+
SVNOptions:
45+
SVNUpdateOptions:
46+
47+
# Git options
48+
GITCommand: /opt/homebrew/bin/git
49+
GITInitSubmodules:
50+
GITUpdateOptions:
51+
GITUpdateCustom:
52+
53+
# Perforce options
54+
P4Command:
55+
P4Client:
56+
P4Options:
57+
P4UpdateOptions:
58+
P4UpdateCustom:
59+
60+
# Generic update command
61+
UpdateCommand: /opt/homebrew/bin/git
62+
UpdateOptions:
63+
UpdateType: git
64+
65+
# Compiler info
66+
Compiler:
67+
CompilerVersion:
68+
69+
# Dynamic analysis (MemCheck)
70+
PurifyCommand:
71+
ValgrindCommand:
72+
ValgrindCommandOptions:
73+
DrMemoryCommand:
74+
DrMemoryCommandOptions:
75+
CudaSanitizerCommand:
76+
CudaSanitizerCommandOptions:
77+
MemoryCheckType:
78+
MemoryCheckSanitizerOptions:
79+
MemoryCheckCommand: MEMORYCHECK_COMMAND-NOTFOUND
80+
MemoryCheckCommandOptions:
81+
MemoryCheckSuppressionFile:
82+
83+
# Coverage
84+
CoverageCommand: /usr/bin/gcov
85+
CoverageExtraFlags: -l
86+
87+
# Testing options
88+
# TimeOut is the amount of time in seconds to wait for processes
89+
# to complete during testing. After TimeOut seconds, the
90+
# process will be summarily terminated.
91+
# Currently set to 25 minutes
92+
TimeOut: 1500
93+
94+
# During parallel testing CTest will not start a new test if doing
95+
# so would cause the system load to exceed this value.
96+
TestLoad:
97+
98+
TLSVerify:
99+
TLSVersion:
100+
101+
UseLaunchers:
102+
CurlOptions:
103+
# warning, if you add new options here that have to do with submit,
104+
# you have to update cmCTestSubmitCommand.cxx
105+
106+
# For CTest submissions that timeout, these options
107+
# specify behavior for retrying the submission
108+
CTestSubmitRetryDelay: 5
109+
CTestSubmitRetryCount: 3
110+
111+
# Invoke each test with environment variables configuring tool's collection.
112+
CTestTestCoverageTool:
113+
CTestTestCoverageMergeExecutable:
114+
CTestTestCoverageDataExecutable:

0 commit comments

Comments
 (0)