Skip to content

Commit

Permalink
PR comments: rework compiler flags
Browse files Browse the repository at this point in the history
  • Loading branch information
lrstewart committed Jun 15, 2023
1 parent d150d3c commit 0b34580
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
12 changes: 5 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,11 @@ if(S2N_UNSAFE_FUZZING_MODE)
target_compile_options(${PROJECT_NAME} PRIVATE -fsanitize-coverage=trace-pc-guard -fsanitize=address,undefined,leak -fuse-ld=gold -DS2N_ADDRESS_SANITIZER=1)
endif()

if(TSAN)
target_compile_options(${PROJECT_NAME} PUBLIC -fsanitize=thread -DS2N_THREAD_SANITIZER=1)
target_link_options(${PROJECT_NAME} PUBLIC -fsanitize=thread)
endif()

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")

if (NOT $ENV{S2N_LIBCRYPTO} MATCHES "awslc")
Expand Down Expand Up @@ -352,13 +357,6 @@ if (NOT S2N_EXECINFO_AVAILABLE)
endif()
feature_probe_result(S2N_STACKTRACE ${S2N_STACKTRACE})

if(TSAN)
target_compile_options(${PROJECT_NAME} PUBLIC -fsanitize=thread)
target_link_options(${PROJECT_NAME} PUBLIC -fsanitize=thread)
# For now, only enable real atomics for TSAN
feature_probe_result(S2N_ATOMIC_ENABLED ${S2N_ATOMIC_SUPPORTED})
endif()

set(S2N_KYBER512R3_AVX2_BMI2 FALSE)
if(NOT S2N_NO_PQ_ASM)
# Kyber Round-3 code has several different optimizations which require
Expand Down
6 changes: 3 additions & 3 deletions utils/s2n_atomic.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@

S2N_RESULT s2n_atomic_init()
{
#if S2N_ATOMIC_ENABLED
#if S2N_ATOMIC_SUPPORTED && S2N_THREAD_SANITIZER
RESULT_ENSURE(__atomic_always_lock_free(sizeof(s2n_atomic_bool), NULL), S2N_ERR_ATOMIC);
#endif
return S2N_RESULT_OK;
}

void s2n_atomic_store(s2n_atomic_bool *var, bool val)
{
#if S2N_ATOMIC_ENABLED
#if S2N_ATOMIC_SUPPORTED && S2N_THREAD_SANITIZER
sig_atomic_t input = val;
__atomic_store(&var->val, &input, __ATOMIC_RELAXED);
#else
Expand All @@ -39,7 +39,7 @@ void s2n_atomic_store(s2n_atomic_bool *var, bool val)

bool s2n_atomic_load(s2n_atomic_bool *var)
{
#if S2N_ATOMIC_ENABLED
#if S2N_ATOMIC_SUPPORTED && S2N_THREAD_SANITIZER
sig_atomic_t result = 0;
__atomic_load(&var->val, &result, __ATOMIC_RELAXED);
return result;
Expand Down

0 comments on commit 0b34580

Please sign in to comment.