[asan] flatten the asan-rt build slightly
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@145631 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/asan/Makefile.old b/lib/asan/Makefile.old
index c796ae8..7c2a7be 100644
--- a/lib/asan/Makefile.old
+++ b/lib/asan/Makefile.old
@@ -7,7 +7,6 @@
#
#===------------------------------------------------------------------------===#
-SVNVERSION=$(shell svnversion)
OS=$(shell uname | tr '[A-Z]' '[a-z]')
ROOT=$(shell pwd)
MAKEFILE=Makefile.old # this file.
@@ -169,44 +168,38 @@
ASAN_LD_TAIL=$(LIBASAN_A)
endif
-RTL_HDR_COMMON=asan_allocator.h \
+RTL_HDR=asan_allocator.h \
asan_internal.h \
asan_interceptors.h \
asan_interface.h \
asan_lock.h \
+ asan_mac.h \
asan_mapping.h \
asan_stack.h \
asan_stats.h \
asan_thread.h \
asan_thread_registry.h \
+ mach_override/mach_override.h \
sysinfo/basictypes.h \
sysinfo/sysinfo.h
-LIBASAN_OBJ_COMMON=$(BIN)/asan_rtl$(SUFF).o \
+LIBASAN_OBJ=$(BIN)/asan_rtl$(SUFF).o \
$(BIN)/asan_allocator$(SUFF).o \
$(BIN)/asan_globals$(SUFF).o \
$(BIN)/asan_interceptors$(SUFF).o \
+ $(BIN)/asan_linux$(SUFF).o \
+ $(BIN)/asan_mac$(SUFF).o \
+ $(BIN)/asan_malloc_linux$(SUFF).o \
+ $(BIN)/asan_malloc_mac$(SUFF).o \
$(BIN)/asan_poisoning$(SUFF).o \
$(BIN)/asan_printf$(SUFF).o \
$(BIN)/asan_stack$(SUFF).o \
$(BIN)/asan_stats$(SUFF).o \
$(BIN)/asan_thread$(SUFF).o \
$(BIN)/asan_thread_registry$(SUFF).o \
+ $(BIN)/mach_override/mach_override$(SUFF).o \
$(BIN)/sysinfo/sysinfo$(SUFF).o
-ifeq ($(OS),darwin)
-RTL_HDR=$(RTL_HDR_COMMON) mach_override/mach_override.h asan_mac.h
-LIBASAN_OBJ=$(LIBASAN_OBJ_COMMON) \
- $(BIN)/asan_mac$(SUFF).o \
- $(BIN)/asan_malloc_mac$(SUFF).o \
- $(BIN)/mach_override/mach_override$(SUFF).o
-else
-RTL_HDR=$(RTL_HDR_COMMON)
-LIBASAN_OBJ=$(LIBASAN_OBJ_COMMON) \
- $(BIN)/asan_linux$(SUFF).o \
- $(BIN)/asan_malloc_linux$(SUFF).o
-endif
-
GTEST_ROOT=third_party/googletest
GTEST_INCLUDE=-I$(GTEST_ROOT)/include
GTEST_MAKE_DIR=$(GTEST_ROOT)/make-$(OS)$(SUFF)
@@ -269,7 +262,6 @@
$(BIN)/%$(SUFF).o: %.cc $(RTL_HDR) $(MAKEFILE)
$(CXX) $(PIE) $(CFLAGS) -fPIC -c -o $@ -g $< -Ithird_party \
- -DASAN_REVISION=\"$(SVNVERSION)\" \
-DASAN_USE_SYSINFO=1 \
-DASAN_NEEDS_SEGV=$(ASAN_NEEDS_SEGV) \
-DASAN_HAS_EXCEPTIONS=$(ASAN_HAS_EXCEPTIONS) \
@@ -278,7 +270,6 @@
$(BIN)/%$(SUFF).o: %.c $(RTL_HDR) $(MAKEFILE)
$(CC) $(PIE) $(CFLAGS) -fPIC -c -o $@ -g $< -Ithird_party \
- -DASAN_REVISION=\"$(SVNVERSION)\" \
-DASAN_USE_SYSINFO=1 \
$(ASAN_FLAGS)
diff --git a/lib/asan/asan_internal.h b/lib/asan/asan_internal.h
index 2c64303..16d8e42 100644
--- a/lib/asan/asan_internal.h
+++ b/lib/asan/asan_internal.h
@@ -14,6 +14,10 @@
#ifndef ASAN_INTERNAL_H
#define ASAN_INTERNAL_H
+#if !defined(__linux__) && !defined(__APPLE__)
+# error "This operating system is not supported by AddressSanitizer"
+#endif
+
#include <stdint.h> // for __WORDSIZE
#include <stdlib.h> // for size_t
#include <unistd.h> // for _exit
diff --git a/lib/asan/asan_linux.cc b/lib/asan/asan_linux.cc
index 752300b..ceb722b 100644
--- a/lib/asan/asan_linux.cc
+++ b/lib/asan/asan_linux.cc
@@ -11,6 +11,7 @@
//
// Linux-specific details.
//===----------------------------------------------------------------------===//
+#ifdef __linux__
#include "asan_internal.h"
@@ -46,3 +47,5 @@
}
} // namespace __asan
+
+#endif // __linux__
diff --git a/lib/asan/asan_mac.cc b/lib/asan/asan_mac.cc
index c125eff..0084fb7 100644
--- a/lib/asan/asan_mac.cc
+++ b/lib/asan/asan_mac.cc
@@ -12,9 +12,7 @@
// Mac-specific details.
//===----------------------------------------------------------------------===//
-#ifndef __APPLE__
-#error "This file should be used on Mac OS X only."
-#endif
+#ifdef __APPLE__
#include "asan_mac.h"
@@ -254,3 +252,5 @@
return real_pthread_workqueue_additem_np(workq, wrap_workitem_func, asan_ctxt,
itemhandlep, gencountp);
}
+
+#endif // __APPLE__
diff --git a/lib/asan/asan_mac.h b/lib/asan/asan_mac.h
index f35fd79..32739e7 100644
--- a/lib/asan/asan_mac.h
+++ b/lib/asan/asan_mac.h
@@ -11,6 +11,8 @@
//
// ASan-private header for asan_mac.cc
//===----------------------------------------------------------------------===//
+#ifdef __APPLE__
+
#ifndef ASAN_MAC_H
#define ASAN_MAC_H
@@ -81,3 +83,5 @@
}
#endif // ASAN_MAC_H
+
+#endif // __APPLE__
diff --git a/lib/asan/asan_malloc_linux.cc b/lib/asan/asan_malloc_linux.cc
index 1b96714..9dbc7a1 100644
--- a/lib/asan/asan_malloc_linux.cc
+++ b/lib/asan/asan_malloc_linux.cc
@@ -13,6 +13,7 @@
// We simply define functions like malloc, free, realloc, etc.
// They will replace the corresponding libc functions automagically.
//===----------------------------------------------------------------------===//
+#ifdef __linux__
#include "asan_allocator.h"
#include "asan_interceptors.h"
@@ -137,3 +138,5 @@
return asan_pvalloc(size, &stack);
}
} // extern "C"
+
+#endif // __linux__
diff --git a/lib/asan/asan_malloc_mac.cc b/lib/asan/asan_malloc_mac.cc
index 0f79d1f..3ef17eb 100644
--- a/lib/asan/asan_malloc_mac.cc
+++ b/lib/asan/asan_malloc_mac.cc
@@ -12,6 +12,8 @@
// Mac-specific malloc interception.
//===----------------------------------------------------------------------===//
+#ifdef __APPLE__
+
#include <AvailabilityMacros.h>
#include <CoreFoundation/CFBase.h>
#include <malloc/malloc.h>
@@ -378,3 +380,5 @@
}
}
} // namespace __asan
+
+#endif // __APPLE__
diff --git a/lib/asan/asan_rtl.cc b/lib/asan/asan_rtl.cc
index bb9c7b1..7fb3b92 100644
--- a/lib/asan/asan_rtl.cc
+++ b/lib/asan/asan_rtl.cc
@@ -753,6 +753,6 @@
__asan_force_interface_symbols(); // no-op.
if (FLAG_v) {
- Report("AddressSanitizer r%s Init done ***\n", ASAN_REVISION);
+ Report("AddressSanitizer Init done\n");
}
}
diff --git a/lib/asan/mach_override/mach_override.c b/lib/asan/mach_override/mach_override.c
index c0342f4..342fefc 100644
--- a/lib/asan/mach_override/mach_override.c
+++ b/lib/asan/mach_override/mach_override.c
@@ -5,6 +5,8 @@
***************************************************************************/
+#ifdef __APPLE__
+
#include "mach_override.h"
#include <mach-o/dyld.h>
@@ -769,3 +771,5 @@
}
#endif
#endif
+
+#endif // __APPLE__
diff --git a/lib/asan/mach_override/mach_override.h b/lib/asan/mach_override/mach_override.h
index 76fdb1b..f1aa617 100644
--- a/lib/asan/mach_override/mach_override.h
+++ b/lib/asan/mach_override/mach_override.h
@@ -42,6 +42,8 @@
***************************************************************************/
+#ifdef __APPLE__
+
#ifndef _mach_override_
#define _mach_override_
@@ -119,3 +121,5 @@
}
#endif
#endif // _mach_override_
+
+#endif // __APPLE__