summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Xu (Hello71) <alex_y_xu@yahoo.ca>2018-04-21 21:26:44 -0400
committerAlex Xu (Hello71) <alex_y_xu@yahoo.ca>2018-04-29 11:33:26 -0400
commit469dc4e8f18d2b68815b93890bda9cfe016490e5 (patch)
tree194b469c223472bf079e3d41e52fe4491ac68b3b
parent3175cfd9593c6bcafa82ad5ddaaca42715493e79 (diff)
downloadtor-469dc4e8f18d2b68815b93890bda9cfe016490e5.tar.xz
tor-469dc4e8f18d2b68815b93890bda9cfe016490e5.zip
improve fragile hardening
-rw-r--r--meson.build24
-rw-r--r--src/rust/meson.build15
2 files changed, 32 insertions, 7 deletions
diff --git a/meson.build b/meson.build
index d6b17dd94..a98fd72f6 100644
--- a/meson.build
+++ b/meson.build
@@ -8,8 +8,28 @@ add_project_arguments('-DTOR_UNIT_TESTS', language: 'c')
cc = meson.get_compiler('c')
if get_option('fragile_hardening')
- add_project_arguments('-fsanitize=address', language: 'c')
- add_project_link_arguments('-fsanitize=address', language: 'c')
+ if cc.has_argument('-fsanitize=address')
+ if cc.get_id() == 'gcc'
+ if cc.version().version_compare('<8')
+ error('ASan from gcc <8 not compatible with LLVM ASan')
+ endif
+
+ if not cc.links('int main(){}', args: ['-fsanitize=address', '-static-libasan'])
+ error('your gcc can\'t link -static-libasan, required for Rust tests. install static libasan or use clang.')
+ endif
+
+ add_project_link_arguments('-static-libasan', language: 'c')
+
+ warning('gcc lags behind on ASan, if you get weird errors try clang')
+ endif
+
+ add_project_arguments('-fsanitize=address', language: 'c')
+ add_project_link_arguments('-fsanitize=address', language: 'c')
+ endif
+
+ add_args = cc.get_supported_arguments(['-ftrapv', '-fsanitize=undefined', '-fno-sanitize-recover=all'])
+ add_project_arguments(add_args, language: 'c')
+ add_project_link_arguments(add_args, language: 'c')
endif
orconf = configuration_data()
diff --git a/src/rust/meson.build b/src/rust/meson.build
index 8a32bc80f..47db35e7e 100644
--- a/src/rust/meson.build
+++ b/src/rust/meson.build
@@ -16,15 +16,20 @@ if get_option('fragile_hardening')
endif
cargo_test_env = environment()
+
+# used in build.rs
cargo_test_env.set('abs_top_builddir', meson.build_root())
+cargo_test_env.set('ASAN_OPTIONS', 'detect_odr_violation=1')
+
# https://github.com/rust-lang/cargo/issues/3366
-if host_machine.system() != 'windows' and host_machine.system() != 'cygwin'
+if host_machine.system() == 'windows'
+ ld_library_path_var = 'PATH'
+elif host_machine.system() == 'darwin'
+ ld_library_path_var = 'DYLD_LIBRARY_PATH'
+else
ld_library_path_var = 'LD_LIBRARY_PATH'
- if host_machine.system() == 'darwin'
- ld_library_path_var = 'DYLD_LIBRARY_PATH'
- endif
- cargo_test_env.prepend(ld_library_path_var, meson.build_root() + '/src/or')
endif
+cargo_test_env.prepend(ld_library_path_var, meson.build_root() + '/src/or')
test('test_rust', cargo, args: cargo_test_args, env: cargo_test_env,
workdir: meson.build_root() + '/src/rust',