Changeset 267130 in webkit
- Timestamp:
- Sep 15, 2020 7:53:36 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 5 added
- 1 deleted
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ChangeLog
r267075 r267130 1 2020-09-15 David Kilzer <ddkilzer@apple.com> 2 3 WebKit should support building with clang ThreadSanitizer enabled 4 <https://webkit.org/b/216318> 5 <rdar://problem/31615729> 6 7 Reviewed by Darin Adler. 8 9 This patch doesn't attempt to resolve every potential false 10 positive, but makes it easy to build WebKit with TSan enabled. 11 12 * Makefile.shared: 13 - Update to work with `make [args] TSAN=YES`. 14 1 15 2020-09-14 Fujii Hironori <Hironori.Fujii@sony.com> 2 16 -
trunk/Makefile.shared
r265602 r267130 71 71 endif 72 72 73 ifeq ($(TSAN),YES) 74 TSAN_OPTION=--tsan 75 else 76 ifeq ($(TSAN),NO) 77 TSAN_OPTION=--no-tsan 78 endif 79 endif 80 73 81 ifeq ($(WK_LTO_MODE),full) 74 82 WK_LTO_OPTION=--lto-mode=full … … 85 93 export PATH = $(shell getconf PATH) 86 94 87 all: set_ asan_configuration95 all: set_sanitizer_configuration 88 96 ( $(SET_COLOR_DIAGNOSTICS_ARG); xcodebuild $(OTHER_OPTIONS) $(XCODE_OPTIONS) GCC_PREPROCESSOR_DEFINITIONS='$(GCC_PREPROCESSOR_ADDITIONS) $$(inherited)' | $(OUTPUT_FILTER) && exit $${PIPESTATUS[0]} ) 89 97 90 98 debug d development dev develop: force 91 $(SCRIPTS_PATH)/set-webkit-configuration --debug $(ASAN_OPTION) $( WK_LTO_OPTION)99 $(SCRIPTS_PATH)/set-webkit-configuration --debug $(ASAN_OPTION) $(TSAN_OPTION) $(WK_LTO_OPTION) 92 100 ( $(SET_COLOR_DIAGNOSTICS_ARG); xcodebuild $(OTHER_OPTIONS) $(XCODE_OPTIONS) GCC_PREPROCESSOR_DEFINITIONS='$(GCC_PREPROCESSOR_ADDITIONS) $$(inherited)' | $(OUTPUT_FILTER) && exit $${PIPESTATUS[0]} ) 93 101 94 102 release r deployment dep deploy: force 95 $(SCRIPTS_PATH)/set-webkit-configuration --release $(ASAN_OPTION) $( WK_LTO_OPTION)103 $(SCRIPTS_PATH)/set-webkit-configuration --release $(ASAN_OPTION) $(TSAN_OPTION) $(WK_LTO_OPTION) 96 104 ( $(SET_COLOR_DIAGNOSTICS_ARG); xcodebuild $(OTHER_OPTIONS) $(XCODE_OPTIONS) GCC_PREPROCESSOR_DEFINITIONS='$(GCC_PREPROCESSOR_ADDITIONS) $$(inherited)' | $(OUTPUT_FILTER) && exit $${PIPESTATUS[0]} ) 97 105 98 106 release+assert ra: force 99 $(SCRIPTS_PATH)/set-webkit-configuration --release $(ASAN_OPTION) $( WK_LTO_OPTION)107 $(SCRIPTS_PATH)/set-webkit-configuration --release $(ASAN_OPTION) $(TSAN_OPTION) $(WK_LTO_OPTION) 100 108 ( $(SET_COLOR_DIAGNOSTICS_ARG); xcodebuild $(OTHER_OPTIONS) $(XCODE_OPTIONS) GCC_PREPROCESSOR_DEFINITIONS='$(GCC_PREPROCESSOR_ADDITIONS) ASSERT_ENABLED=1 $$(inherited)' | $(OUTPUT_FILTER) && exit $${PIPESTATUS[0]} ) 101 109 102 110 testing t: force 103 $(SCRIPTS_PATH)/set-webkit-configuration --debug $(ASAN_OPTION) $( WK_LTO_OPTION) --force-optimization-level=O3111 $(SCRIPTS_PATH)/set-webkit-configuration --debug $(ASAN_OPTION) $(TSAN_OPTION) $(WK_LTO_OPTION) --force-optimization-level=O3 104 112 ( $(SET_COLOR_DIAGNOSTICS_ARG); xcodebuild $(OTHER_OPTIONS) $(XCODE_OPTIONS) GCC_PREPROCESSOR_DEFINITIONS='$(GCC_PREPROCESSOR_ADDITIONS) $$(inherited)' | $(OUTPUT_FILTER) && exit $${PIPESTATUS[0]} ) 105 113 106 114 analyze: 107 $(SCRIPTS_PATH)/set-webkit-configuration --debug $(ASAN_OPTION) $( WK_LTO_OPTION)115 $(SCRIPTS_PATH)/set-webkit-configuration --debug $(ASAN_OPTION) $(TSAN_OPTION) $(WK_LTO_OPTION) 108 116 ifndef PATH_TO_SCAN_BUILD 109 117 ( $(SET_COLOR_DIAGNOSTICS_ARG); xcodebuild $(OTHER_OPTIONS) $(XCODE_OPTIONS) GCC_PREPROCESSOR_DEFINITIONS='$(GCC_PREPROCESSOR_ADDITIONS) $$(inherited)' RUN_CLANG_STATIC_ANALYZER=YES | $(OUTPUT_FILTER) && exit $${PIPESTATUS[0]} ) … … 112 120 endif 113 121 114 set_ asan_configuration:122 set_sanitizer_configuration: 115 123 ifneq (,$(ASAN_OPTION)) 116 124 $(SCRIPTS_PATH)/set-webkit-configuration $(ASAN_OPTION) 125 endif 126 ifneq (,$(TSAN_OPTION)) 127 $(SCRIPTS_PATH)/set-webkit-configuration $(TSAN_OPTION) 117 128 endif 118 129 -
trunk/Source/WTF/ChangeLog
r267116 r267130 1 2020-09-15 David Kilzer <ddkilzer@apple.com> 2 3 WebKit should support building with clang ThreadSanitizer enabled 4 <https://webkit.org/b/216318> 5 <rdar://problem/31615729> 6 7 Reviewed by Darin Adler. 8 9 This patch doesn't attempt to resolve every potential false 10 positive, but makes it easy to build WebKit with TSan enabled. 11 12 * WTF.xcodeproj/project.pbxproj: 13 * wtf/CMakeLists.txt: 14 - Add ThreadSanitizerSupport.h to the project. 15 16 * wtf/Compiler.h: 17 - Define TSAN_ENABLED and SUPPRESS_TSAN macros. 18 19 * wtf/Locker.h: 20 (WTF::Locker::~Locker): 21 (WTF::Locker::unlockEarly): 22 (WTF::Locker::operator=): 23 (WTF::Locker::lock): 24 - Instrument lock/unlock methods for ThreadSanitizer. 25 26 * wtf/ThreadSanitizerSupport.h: Add. 27 (AnnotateHappensBefore): 28 (AnnotateHappensAfter): 29 - Declare TSan runtime functions needed to annotate WTF::Locker. 30 (TSAN_ANNOTATE_HAPPENS_BEFORE): 31 (TSAN_ANNOTATE_HAPPENS_AFTER): 32 - Define macros used to call TSan runtime functions if TSan is 33 enabled. 34 1 35 2020-09-15 Myles C. Maxfield <mmaxfield@apple.com> 2 36 -
trunk/Source/WTF/WTF.xcodeproj/project.pbxproj
r266573 r267130 374 374 430B47871AAAAC1A001223DA /* StringCommon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StringCommon.h; sourceTree = "<group>"; }; 375 375 4427C5A921F6D6C300A612A4 /* ASCIICType.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ASCIICType.cpp; sourceTree = "<group>"; }; 376 4468567225094FE8008CCA05 /* ThreadSanitizerSupport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThreadSanitizerSupport.h; sourceTree = "<group>"; }; 376 377 46BA9EAB1F4CD61E009A2BBC /* CompletionHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CompletionHandler.h; sourceTree = "<group>"; }; 377 378 46BEB6E922FFDDD500269867 /* RefCounted.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RefCounted.cpp; sourceTree = "<group>"; }; … … 1270 1271 5311BD591EA81A9600525281 /* ThreadMessage.h */, 1271 1272 A8A4733E151A825B004123FF /* ThreadSafeRefCounted.h */, 1273 4468567225094FE8008CCA05 /* ThreadSanitizerSupport.h */, 1272 1274 A8A4733F151A825B004123FF /* ThreadSpecific.h */, 1273 1275 0F66B2861DC97BAB004A1D3F /* TimeWithDynamicClockType.cpp */, -
trunk/Source/WTF/wtf/CMakeLists.txt
r266573 r267130 261 261 ThreadMessage.h 262 262 ThreadSafeRefCounted.h 263 ThreadSanitizerSupport.h 263 264 ThreadSpecific.h 264 265 Threading.h -
trunk/Source/WTF/wtf/Compiler.h
r260027 r267130 157 157 #endif 158 158 159 /* TSAN_ENABLED and SUPPRESS_TSAN */ 160 161 #ifdef __SANITIZE_THREAD__ 162 #define TSAN_ENABLED 1 163 #else 164 #define TSAN_ENABLED COMPILER_HAS_CLANG_FEATURE(thread_sanitizer) 165 #endif 166 167 #if TSAN_ENABLED 168 #define SUPPRESS_TSAN __attribute__((no_sanitize_thread)) 169 #else 170 #define SUPPRESS_TSAN 171 #endif 172 159 173 /* ==== Compiler-independent macros for various compiler features, in alphabetical order ==== */ 160 174 -
trunk/Source/WTF/wtf/Locker.h
r244352 r267130 1 1 /* 2 * Copyright (C) 2008-20 17Apple Inc. All rights reserved.2 * Copyright (C) 2008-2020 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 33 33 #include <wtf/Compiler.h> 34 34 #include <wtf/Noncopyable.h> 35 #include <wtf/ThreadSanitizerSupport.h> 35 36 36 37 namespace WTF { … … 68 69 { 69 70 compilerFence(); 70 if (m_lockable) 71 if (m_lockable) { 72 TSAN_ANNOTATE_HAPPENS_BEFORE(m_lockable); 71 73 m_lockable->unlock(); 74 } 72 75 } 73 76 … … 86 89 void unlockEarly() 87 90 { 91 TSAN_ANNOTATE_HAPPENS_BEFORE(m_lockable); 88 92 m_lockable->unlock(); 89 m_lockable = 0;93 m_lockable = nullptr; 90 94 } 91 95 … … 100 104 Locker& operator=(Locker&& other) 101 105 { 102 if (m_lockable) 106 if (m_lockable) { 107 TSAN_ANNOTATE_HAPPENS_BEFORE(m_lockable); 103 108 m_lockable->unlock(); 109 } 104 110 m_lockable = other.m_lockable; 105 111 other.m_lockable = nullptr; … … 110 116 void lock() 111 117 { 112 if (m_lockable) 118 if (m_lockable) { 113 119 m_lockable->lock(); 120 TSAN_ANNOTATE_HAPPENS_AFTER(m_lockable); 121 } 114 122 compilerFence(); 115 123 } -
trunk/Tools/ChangeLog
r267123 r267130 1 2020-09-15 David Kilzer <ddkilzer@apple.com> 2 3 WebKit should support building with clang ThreadSanitizer enabled 4 <https://webkit.org/b/216318> 5 <rdar://problem/31615729> 6 7 Reviewed by Darin Adler. 8 9 This patch doesn't attempt to resolve every potential false 10 positive, but makes it easy to build WebKit with TSan enabled. 11 12 * Scripts/set-webkit-configuration: 13 - Add support for --[no-]tsan switches. 14 * Scripts/webkitdirs.pm: 15 (determineTSanIsEnabled): 16 (tsanIsEnabled): 17 (XcodeOptions): 18 (generateBuildSystemFromCMakeProject): 19 - Add support for building with TSan enabled. 20 21 * asan/asan.xcconfig: Rename to sanitizer/asan.xcconfig. 22 * sanitizer/asan.xcconfig: Rename from asan/asan.xcconfig. 23 - Extract common variables to sanitizer.xcconfig. 24 * sanitizer/sanitizer.xcconfig: Add. 25 - Extract common variables from asan.xcconfig. 26 * sanitizer/tsan.xcconfig: Add. 27 - Add support for TSan. 28 1 29 2020-09-15 Alex Christensen <achristensen@webkit.org> 2 30 -
trunk/Tools/Scripts/set-webkit-configuration
r255160 r267130 1 1 #!/usr/bin/env perl 2 2 3 # Copyright (C) 2005-20 19Apple Inc. All rights reserved.3 # Copyright (C) 2005-2020 Apple Inc. All rights reserved. 4 4 # 5 5 # Redistribution and use in source and binary forms, with or without … … 29 29 use strict; 30 30 use warnings; 31 use File::Spec; 31 32 use FindBin; 32 33 use lib $FindBin::Bin; … … 40 41 --[no-]asan Enable or disable clang address sanitizer 41 42 --[no-]coverage Enable or disable LLVM Source-based Code Coverage 43 --[no-]tsan Enable or disable clang thread sanitizer 42 44 --force-optimization-level=<level> Optimization level: O3, O2, O1, O0, Os, Ofast, Og, or none 43 45 --lto-mode=<mode> Set LTO mode: full, thin, or none … … 53 55 my $enableCoverage = checkForArgumentAndRemoveFromARGV("--coverage"); 54 56 my $disableCoverage = checkForArgumentAndRemoveFromARGV("--no-coverage"); 57 my $enableTSAN = checkForArgumentAndRemoveFromARGV("--tsan"); 58 my $disableTSAN = checkForArgumentAndRemoveFromARGV("--no-tsan"); 55 59 my $ltoMode; 56 60 if (!checkForArgumentAndRemoveFromARGVGettingValue("--lto-mode", \$ltoMode)) { … … 81 85 unlink "$baseProductDir/Architecture"; 82 86 unlink "$baseProductDir/ASan"; 87 unlink "$baseProductDir/Coverage"; 88 unlink File::Spec->catfile($baseProductDir, "TSan"); 83 89 unlink "$baseProductDir/ForceOptimizationLevel"; 84 unlink "$baseProductDir/Coverage";85 90 unlink "$baseProductDir/LTO"; 86 91 exit 0; 87 92 } 88 93 89 if ((!$configuration && !$architecture && !$enableASAN && !$disableASAN && !$enableCoverage && !$disableCoverage && !$ ltoMode && !$forceOptimizationLevel)94 if ((!$configuration && !$architecture && !$enableASAN && !$disableASAN && !$enableCoverage && !$disableCoverage && !$enableTSAN && !$disableTSAN && !$ltoMode && !$forceOptimizationLevel) 90 95 || ($enableASAN && $disableASAN) 91 || ($enableCoverage && $disableCoverage)) { 96 || ($enableCoverage && $disableCoverage) 97 || ($enableTSAN && $disableTSAN) 98 ) { 92 99 print STDERR $usage; 93 100 exit 1; … … 144 151 } 145 152 153 if ($enableTSAN) { 154 open TSAN, ">", File::Spec->catfile($baseProductDir, "TSan") or die; 155 print TSAN "YES"; 156 close TSAN; 157 } elsif ($disableTSAN) { 158 unlink File::Spec->catfile($baseProductDir, "TSan"); 159 } 160 146 161 if ($forceOptimizationLevel && $forceOptimizationLevel eq "none") { 147 162 unlink "$baseProductDir/ForceOptimizationLevel"; -
trunk/Tools/Scripts/webkitdirs.pm
r265323 r267130 1 # Copyright (C) 2005-20 19Apple Inc. All rights reserved.1 # Copyright (C) 2005-2020 Apple Inc. All rights reserved. 2 2 # Copyright (C) 2009 Google Inc. All rights reserved. 3 3 # Copyright (C) 2011 Research In Motion Limited. All rights reserved. … … 131 131 my %nativeArchitectureMap = (); 132 132 my $asanIsEnabled; 133 my $tsanIsEnabled; 133 134 my $forceOptimizationLevel; 134 135 my $coverageIsEnabled; … … 447 448 } 448 449 450 sub determineTSanIsEnabled 451 { 452 return if defined $tsanIsEnabled; 453 determineBaseProductDir(); 454 455 $tsanIsEnabled = 0; 456 my $tsanConfigurationValue; 457 458 if (open TSAN, "$baseProductDir/TSan") { 459 $tsanConfigurationValue = <TSAN>; 460 close TSAN; 461 chomp $tsanConfigurationValue; 462 $tsanIsEnabled = 1 if $tsanConfigurationValue eq "YES"; 463 } 464 } 465 449 466 sub determineForceOptimizationLevel 450 467 { … … 886 903 } 887 904 905 sub tsanIsEnabled() 906 { 907 determineTSanIsEnabled(); 908 return $tsanIsEnabled; 909 } 910 888 911 sub forceOptimizationLevel() 889 912 { … … 940 963 determineArchitecture(); 941 964 determineASanIsEnabled(); 965 determineTSanIsEnabled(); 942 966 determineForceOptimizationLevel(); 943 967 determineCoverageIsEnabled(); … … 949 973 push @options, "-ShowBuildOperationDuration=YES"; 950 974 push @options, ("-configuration", $configuration); 951 push @options, ("-xcconfig", sourceDir() . "/Tools/asan/asan.xcconfig", "ASAN_IGNORE=" . sourceDir() . "/Tools/asan/webkit-asan-ignore.txt") if $asanIsEnabled; 975 if ($asanIsEnabled) { 976 push @options, ("-xcconfig", File::Spec->catfile(sourceDir(), "Tools", "sanitizer", "asan.xcconfig")); 977 my $asanIgnorePath = File::Spec->catfile(sourceDir(), "Tools", "sanitizer", "webkit-asan-ignore.txt"); 978 push @options, "ASAN_IGNORE=$asanIgnorePath" if -e $asanIgnorePath; 979 } elsif ($tsanIsEnabled) { 980 push @options, ("-xcconfig", File::Spec->catfile(sourceDir(), "Tools", "sanitizer", "tsan.xcconfig")); 981 } 952 982 push @options, ("-xcconfig", sourceDir() . "/Tools/coverage/coverage.xcconfig") if $coverageIsEnabled; 953 983 push @options, ("GCC_OPTIMIZATION_LEVEL=$forceOptimizationLevel") if $forceOptimizationLevel; … … 961 991 appendToEnvironmentVariableList("WEBKIT_COVERAGE_BUILD", "1") if $coverageIsEnabled; 962 992 963 die "cannot enable both ASAN and Coverage at this time\n" if $coverageIsEnabled && $asanIsEnabled; 993 die "Cannot enable both ASAN and TSAN at the same time\n" if $asanIsEnabled && $tsanIsEnabled; 994 die "Cannot enable both (ASAN or TSAN) and Coverage at this time\n" if $coverageIsEnabled && ($asanIsEnabled || $tsanIsEnabled); 964 995 965 996 if (willUseIOSDeviceSDK() || willUseWatchDeviceSDK() || willUseAppleTVDeviceSDK()) { … … 2434 2465 2435 2466 push @args, "-DENABLE_SANITIZERS=address" if asanIsEnabled(); 2467 push @args, "-DENABLE_SANITIZERS=thread" if tsanIsEnabled(); 2436 2468 2437 2469 push @args, "-DLTO_MODE=$ltoMode" if ltoMode();
Note: See TracChangeset
for help on using the changeset viewer.