Skip to content

Commit 44bf1c9

Browse files
committed
Revert "Remove support for building sanitizers from Makefile/autoconf build."
This reverts commit r229554. Reverting this commit for now as several apple internal builds still rely on this functionality. llvm-svn: 229582
1 parent e194dfa commit 44bf1c9

File tree

4 files changed

+49
-10
lines changed

4 files changed

+49
-10
lines changed

clang/docs/AddressSanitizer.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ Typical slowdown introduced by AddressSanitizer is **2x**.
2323
How to build
2424
============
2525

26-
Build LLVM/Clang with `CMake <http://llvm.org/docs/CMake.html>`_.
26+
Follow the `clang build instructions <../get_started.html>`_. CMake build is
27+
supported.
2728

2829
Usage
2930
=====

clang/docs/MemorySanitizer.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ Typical slowdown introduced by MemorySanitizer is **3x**.
1616
How to build
1717
============
1818

19-
Build LLVM/Clang with `CMake <http://llvm.org/docs/CMake.html>`_.
19+
Follow the `clang build instructions <../get_started.html>`_. CMake
20+
build is supported.
2021

2122
Usage
2223
=====

clang/docs/ThreadSanitizer.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ ThreadSanitizer is about **5x-10x**.
1212
How to build
1313
------------
1414

15-
Build LLVM/Clang with `CMake <http://llvm.org/docs/CMake.html>`_.
15+
Follow the `Clang build instructions <../get_started.html>`_. CMake build is
16+
supported.
1617

1718
Supported Platforms
1819
-------------------

clang/runtime/compiler-rt/Makefile

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ ResourceDir := $(PROJ_OBJ_ROOT)/$(BuildMode)/lib/clang/$(CLANG_VERSION)
2323
PROJ_resources := $(DESTDIR)$(PROJ_prefix)/lib/clang/$(CLANG_VERSION)
2424

2525
ResourceLibDir := $(ResourceDir)/lib
26+
ResourceIncludeDir := $(ResourceDir)/include
2627
PROJ_resources_lib := $(PROJ_resources)/lib
28+
PROJ_resources_include := $(PROJ_resources)/include
2729

2830
# Expect compiler-rt to be in llvm/projects/compiler-rt
2931
COMPILERRT_SRC_ROOT := $(LLVM_SRC_ROOT)/projects/compiler-rt
@@ -75,7 +77,9 @@ ifeq ($(OS),Darwin)
7577
RuntimeDirs += darwin macho_embedded
7678
RuntimeLibrary.darwin.Configs := \
7779
eprintf.a 10.4.a osx.a cc_kext.a \
78-
profile_osx.a
80+
asan_osx_dynamic.dylib \
81+
profile_osx.a \
82+
ubsan_osx.a
7983

8084
IOS_SDK := $(shell xcrun --show-sdk-path -sdk iphoneos 2> /dev/null)
8185
IOSSIM_SDK := $(shell xcrun --show-sdk-path -sdk iphonesimulator 2> /dev/null)
@@ -88,6 +92,10 @@ ifneq ($(IOS_SDK),)
8892
RuntimeLibrary.darwin.Configs += cc_kext_ios5.a
8993
endif
9094

95+
ifneq ($(IOSSIM_SDK),)
96+
RuntimeLibrary.darwin.Configs += asan_iossim_dynamic.dylib
97+
endif
98+
9199
RuntimeLibrary.macho_embedded.Configs := \
92100
hard_static.a hard_pic.a
93101
ifneq (,$(findstring ARM,$(TARGETS_TO_BUILD)))
@@ -114,7 +122,8 @@ TryCompile = \
114122

115123
# We try to build 32-bit runtimes both on 32-bit hosts and 64-bit hosts.
116124
Runtime32BitConfigs = \
117-
builtins-i386.a profile-i386.a
125+
builtins-i386.a profile-i386.a san-i386.a asan-i386.a asan_cxx-i386.a \
126+
ubsan-i386.a ubsan_cxx-i386.a
118127

119128
# We currently only try to generate runtime libraries on x86.
120129
ifeq ($(ARCH),x86)
@@ -123,15 +132,21 @@ endif
123132

124133
ifeq ($(ARCH),x86_64)
125134
RuntimeLibrary.linux.Configs += \
126-
builtins-x86_64.a profile-x86_64.a
127-
# We need to build 32-bit libraries on 64-bit platform, and add them
128-
# to the list of runtime libraries to make "clang -m32" work.
135+
builtins-x86_64.a profile-x86_64.a san-x86_64.a asan-x86_64.a \
136+
asan_cxx-x86_64.a tsan-x86_64.a msan-x86_64.a ubsan-x86_64.a \
137+
ubsan_cxx-x86_64.a dfsan-x86_64.a lsan-x86_64.a
138+
# We need to build 32-bit ASan/UBsan libraries on 64-bit platform, and add them
139+
# to the list of runtime libraries to make
140+
# "clang -fsanitize=(address|undefined) -m32" work.
129141
# We check that Clang can produce working 32-bit binaries by compiling a simple
130142
# executable.
131143
test_source = $(LLVM_SRC_ROOT)/tools/clang/runtime/compiler-rt/clang_linux_test_input.c
132144
ifeq ($(call TryCompile,$(ToolDir)/clang,$(test_source),-m32),0)
133145
RuntimeLibrary.linux.Configs += $(Runtime32BitConfigs)
134146
endif
147+
ifneq ($(LLVM_ANDROID_TOOLCHAIN_DIR),)
148+
RuntimeLibrary.linux.Configs += asan-arm-android.so
149+
endif
135150
endif
136151

137152
endif
@@ -151,6 +166,7 @@ BuildRuntimeLibraries:
151166
ProjObjRoot=$(PROJ_OBJ_DIR) \
152167
CC="$(ToolDir)/clang" \
153168
VERBOSE=$(VERBOSE) \
169+
LLVM_ANDROID_TOOLCHAIN_DIR="$(LLVM_ANDROID_TOOLCHAIN_DIR)" \
154170
$(RuntimeDirs:%=clang_%)
155171
.PHONY: BuildRuntimeLibraries
156172
CleanRuntimeLibraries:
@@ -160,10 +176,18 @@ CleanRuntimeLibraries:
160176
VERBOSE=$(VERBOSE) \
161177
clean
162178
.PHONY: CleanRuntimeLibraries
179+
RuntimeHeader: $(ResourceIncludeDir)/sanitizer
163180

164181
$(PROJ_resources_lib):
165182
$(Verb) $(MKDIR) $@
166183

184+
$(ResourceIncludeDir):
185+
$(Verb) $(MKDIR) $@
186+
187+
$(ResourceIncludeDir)/sanitizer: $(ResourceIncludeDir)
188+
$(Verb) $(MKDIR) $@
189+
$(Verb) cp $(COMPILERRT_SRC_ROOT)/include/sanitizer/*.h $@
190+
167191
# Expand rules for copying/installing each individual library. We can't use
168192
# implicit rules here because we need to match against multiple things.
169193
define RuntimeLibraryTemplate
@@ -218,9 +242,21 @@ RuntimeLibraryInstall.$1: \
218242
endef
219243
$(foreach lib,$(RuntimeDirs), $(eval $(call RuntimeLibraryTemplate,$(lib))))
220244

245+
$(PROJ_resources_include):
246+
$(Verb) $(MKDIR) $@
247+
248+
$(PROJ_resources_include)/sanitizer: $(ResourceIncludeDir)/sanitizer $(PROJ_resources_include)
249+
$(Verb) $(MKDIR) $@
250+
$(Echo) Installing compiler runtime headers
251+
$(Verb) $(DataInstall) $(ResourceIncludeDir)/sanitizer/* \
252+
$(PROJ_resources_include)/sanitizer
253+
254+
RuntimeHeaderInstall: $(PROJ_resources_include)/sanitizer
255+
.PHONY: RuntimeHeaderInstall
256+
221257
# Hook into the standard Makefile rules.
222-
all-local:: $(RuntimeDirs:%=RuntimeLibrary.%)
223-
install-local:: $(RuntimeDirs:%=RuntimeLibraryInstall.%)
258+
all-local:: $(RuntimeDirs:%=RuntimeLibrary.%) RuntimeHeader
259+
install-local:: $(RuntimeDirs:%=RuntimeLibraryInstall.%) RuntimeHeaderInstall
224260
clean-local:: CleanRuntimeLibraries
225261

226262
endif

0 commit comments

Comments
 (0)