File tree Expand file tree Collapse file tree 7 files changed +29
-2
lines changed Expand file tree Collapse file tree 7 files changed +29
-2
lines changed Original file line number Diff line number Diff line change @@ -98,6 +98,8 @@ session_sanitizer_cfi_requires_single_codegen_unit = `-Zsanitizer=cfi` with `-Cl
98
98
99
99
session_sanitizer_kcfi_requires_panic_abort = `-Z sanitizer=kcfi` requires `-C panic=abort`
100
100
101
+ session_sanitizer_leak_requires_export_executable_symbols = `-Zsanitizer=leak` requires `-Zexport-executable-symbols`
102
+
101
103
session_sanitizer_not_supported = { $us } sanitizer is not supported for this target
102
104
103
105
session_sanitizers_not_supported = { $us } sanitizers are not supported for this target
Original file line number Diff line number Diff line change @@ -127,6 +127,10 @@ pub(crate) struct CannotMixAndMatchSanitizers {
127
127
#[ diag( session_cannot_enable_crt_static_linux) ]
128
128
pub ( crate ) struct CannotEnableCrtStaticLinux ;
129
129
130
+ #[ derive( Diagnostic ) ]
131
+ #[ diag( session_sanitizer_leak_requires_export_executable_symbols) ]
132
+ pub ( crate ) struct SanitizerLeakRequiresExportExecutableSymbols ;
133
+
130
134
#[ derive( Diagnostic ) ]
131
135
#[ diag( session_sanitizer_cfi_requires_lto) ]
132
136
pub ( crate ) struct SanitizerCfiRequiresLto ;
Original file line number Diff line number Diff line change @@ -390,6 +390,10 @@ impl Session {
390
390
self . opts . unstable_opts . sanitizer . contains ( SanitizerSet :: KCFI )
391
391
}
392
392
393
+ pub fn is_sanitizer_leak_enabled ( & self ) -> bool {
394
+ self . opts . unstable_opts . sanitizer . contains ( SanitizerSet :: LEAK )
395
+ }
396
+
393
397
pub fn is_split_lto_unit_enabled ( & self ) -> bool {
394
398
self . opts . unstable_opts . split_lto_unit == Some ( true )
395
399
}
@@ -1223,6 +1227,11 @@ fn validate_commandline_args_with_session_available(sess: &Session) {
1223
1227
sess. dcx ( ) . emit_err ( errors:: CannotEnableCrtStaticLinux ) ;
1224
1228
}
1225
1229
1230
+ // LeakSanitizer requires export_executable_symbols.
1231
+ if sess. is_sanitizer_leak_enabled ( ) && !sess. opts . unstable_opts . export_executable_symbols {
1232
+ sess. dcx ( ) . emit_err ( errors:: SanitizerLeakRequiresExportExecutableSymbols ) ;
1233
+ }
1234
+
1226
1235
// LLVM CFI requires LTO.
1227
1236
if sess. is_sanitizer_cfi_enabled ( )
1228
1237
&& !( sess. lto ( ) == config:: Lto :: Fat || sess. opts . cg . linker_plugin_lto . enabled ( ) )
Original file line number Diff line number Diff line change 13
13
//@[kcfi]compile-flags: -Zsanitizer=kcfi --cfg kcfi --target x86_64-unknown-none
14
14
//@[kcfi]compile-flags: -C panic=abort
15
15
//@[leak]needs-sanitizer-leak
16
- //@[leak]compile-flags: -Zsanitizer=leak --cfg leak
16
+ //@[leak]compile-flags: -Zsanitizer=leak --cfg leak -Zexport-executable-symbols
17
17
//@[memory]needs-sanitizer-memory
18
18
//@[memory]compile-flags: -Zsanitizer=memory --cfg memory
19
19
//@[thread]needs-sanitizer-thread
Original file line number Diff line number Diff line change
1
+ // Verifies that `-Zsanitizer=leak` requires `-Zexport-executable-symbols`.
2
+ //
3
+ //@ needs-sanitizer-leak
4
+ //@ compile-flags: -Zsanitizer=leak
5
+
6
+ #![ feature( no_core) ]
7
+ #![ no_core]
8
+ #![ no_main]
Original file line number Diff line number Diff line change
1
+ error: `-Zsanitizer=leak` requires `-Zexport-executable-symbols`
2
+
3
+ error: aborting due to 1 previous error
4
+
Original file line number Diff line number Diff line change 1
- //@ compile-flags: -Z sanitizer=leak --target i686-unknown-linux-gnu
1
+ //@ compile-flags: -Z sanitizer=leak -Zexport-executable-symbols - -target i686-unknown-linux-gnu
2
2
//@ needs-llvm-components: x86
3
3
//@ error-pattern: error: leak sanitizer is not supported for this target
4
4
#![ feature( no_core) ]
You can’t perform that action at this time.
0 commit comments