Skip to content

[DNM] Address Sanitizer for Wasm/WASI #81470

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/IRGen/GenDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1992,6 +1992,7 @@ void IRGenerator::emitDynamicReplacements() {
"\x01l_auto_dynamic_replacements", IGM.getPointerAlignment(),
/*isConstant*/ true, llvm::GlobalValue::PrivateLinkage);
autoReplVar->setSection(getDynamicReplacementSection(IGM));
disableAddressSanitizer(IGM, autoReplVar);
IGM.addUsedGlobal(autoReplVar);

if (origFuncTypes.empty())
Expand Down
2 changes: 1 addition & 1 deletion lib/Option/SanitizerOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ OptionSet<SanitizerKind> swift::parseSanitizerArgValues(
}

// Check that we're one of the known supported targets for sanitizers.
if (!(Triple.isOSDarwin() || Triple.isOSLinux() || Triple.isOSWindows())) {
if (!(Triple.isOSDarwin() || Triple.isOSLinux() || Triple.isOSWindows() || Triple.isOSWASI())) {
SmallString<128> b;
Diags.diagnose(SourceLoc(), diag::error_unsupported_opt_for_target,
(A->getOption().getPrefixedName() +
Expand Down
2 changes: 1 addition & 1 deletion test/IRGen/dynamic_replaceable.sil
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
// CHECK: @"\01l_auto_dynamic_replacements" = private constant { i32, i32, [2 x i32] }
// CHECK-SAME: { i32 0, i32 1,
// CHECK-SAME: [2 x i32] [{{.*}}@"\01l_unnamed_dynamic_replacements"{{.*}}, i32 0]
// CHECK-SAME: }, section "__TEXT, __swift5_replace, regular, no_dead_strip"
// CHECK-SAME: }, section "__TEXT, __swift5_replace, regular, no_dead_strip", no_sanitize_address

// CHECK-LABEL: define swiftcc void @test_dynamically_replaceable()
// CHECK-NEXT: entry:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,12 @@ def _build(self, host_target, enable_wasi_threads=False,
self.cmake_options.define('COMPILER_RT_BAREMETAL_BUILD:BOOL', 'TRUE')
self.cmake_options.define('COMPILER_RT_BUILD_XRAY:BOOL', 'FALSE')
self.cmake_options.define('COMPILER_RT_BUILD_PROFILE:BOOL', 'TRUE')
self.cmake_options.define('COMPILER_RT_BUILD_SANITIZERS:BOOL', 'TRUE')
self.cmake_options.define('COMPILER_RT_INCLUDE_TESTS:BOOL', 'FALSE')
self.cmake_options.define('COMPILER_RT_HAS_FPIC_FLAG:BOOL', 'FALSE')
# At this point, CMake feature check for -fno-builtin always fails
# because compiler-rt itself is not built yet and failed to link executable.
self.cmake_options.define('COMPILER_RT_HAS_FNO_BUILTIN_FLAG:BOOL', 'TRUE')
self.cmake_options.define('COMPILER_RT_EXCLUDE_ATOMIC_BUILTIN:BOOL', 'FALSE')
self.cmake_options.define('COMPILER_RT_OS_DIR:STRING', compiler_rt_os_dir)

Expand Down