Page MenuHomeFreeBSD
Paste P512

LLVM on macOS
ActivePublic

Authored by jrtc27 on Mon, Jul 5, 5:22 PM.
diff --git a/lib/clang/include/llvm/Config/config.h b/lib/clang/include/llvm/Config/config.h
index ab8be211be67..ef94aeb6e27e 100644
--- a/lib/clang/include/llvm/Config/config.h
+++ b/lib/clang/include/llvm/Config/config.h
@@ -29,7 +29,11 @@
/* #undef HAVE_CRASHREPORTERCLIENT_H */
/* can use __crashreporter_info__ */
+#if defined(__APPLE__)
+#define HAVE_CRASHREPORTER_INFO 1
+#else
#define HAVE_CRASHREPORTER_INFO 0
+#endif
/* Define to 1 if you have the declaration of `arc4random', and to 0 if you
don't. */
@@ -125,28 +129,46 @@
#define HAVE_PTHREAD_SETNAME_NP 1
/* Define to 1 if you have the <link.h> header file. */
+#if defined(__APPLE__)
+#define HAVE_LINK_H 0
+#else
#define HAVE_LINK_H 1
+#endif
/* Define to 1 if you have the `lseek64' function. */
-/* #undef HAVE_LSEEK64 */
+#if defined(__linux__)
+#define HAVE_LSEEK64 1
+#endif
/* Define to 1 if you have the <mach/mach.h> header file. */
-/* #undef HAVE_MACH_MACH_H */
+#if defined(__APPLE__)
+#define HAVE_MACH_MACH_H 1
+#endif
/* Define to 1 if you have the `mallctl' function. */
+#if defined(__FreeBSD__)
#define HAVE_MALLCTL 1
+#endif
/* Define to 1 if you have the `mallinfo' function. */
-/* #undef HAVE_MALLINFO */
+#if defined(__linux__)
+#define HAVE_MALLINFO 1
+#endif
/* Define to 1 if you have the <malloc/malloc.h> header file. */
-/* #undef HAVE_MALLOC_MALLOC_H */
+#if defined(__APPLE__)
+#define HAVE_MALLOC_MALLOC_H 1
+#endif
/* Define to 1 if you have the `malloc_zone_statistics' function. */
-/* #undef HAVE_MALLOC_ZONE_STATISTICS */
+#if defined(__APPLE__)
+#define HAVE_MALLOC_ZONE_STATISTICS 1
+#endif
/* Define to 1 if you have the `posix_fallocate' function. */
+#if !defined(__APPLE__)
#define HAVE_POSIX_FALLOCATE 1
+#endif
/* Define to 1 if you have the `posix_spawn' function. */
#define HAVE_POSIX_SPAWN 1
@@ -209,19 +231,27 @@
#define HAVE_SYS_TIME_H 1
/* Define to 1 if stat struct has st_mtimespec member .*/
+#if !defined(__linux__)
#define HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC 1
+#endif
/* Define to 1 if stat struct has st_mtim member. */
+#if !defined(__APPLE__)
#define HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC 1
+#endif
/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
/* Define if the setupterm() function is supported this platform. */
+#if !defined(__APPLE__)
#define LLVM_ENABLE_TERMINFO 1
+#endif
/* Define if the xar_open() function is supported this platform. */
-/* #undef HAVE_LIBXAR */
+#if defined(__APPLE__)
+#define HAVE_LIBXAR 1
+#endif
/* Define to 1 if you have the <termios.h> header file. */
#define HAVE_TERMIOS_H 1
@@ -239,7 +269,9 @@
/* #undef HAVE__CHSIZE_S */
/* Define to 1 if you have the `_Unwind_Backtrace' function. */
-/* #undef HAVE__UNWIND_BACKTRACE */
+#if !defined(__FreeBSD__)
+#define HAVE__UNWIND_BACKTRACE 1
+#endif
/* Have host's __alloca */
/* #undef HAVE___ALLOCA */
@@ -315,7 +347,11 @@
/* #undef LLVM_LIBXML2_ENABLED */
/* Define to the extension used for shared libraries, say, ".so". */
+#if defined(__APPLE__)
+#define LTDL_SHLIB_EXT ".dylib"
+#else
#define LTDL_SHLIB_EXT ".so"
+#endif
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT "https://bugs.freebsd.org/submit/"
@@ -351,6 +387,10 @@
/* #undef LLVM_GISEL_COV_PREFIX */
/* Whether Timers signpost passes in Xcode Instruments */
+#if defined(__APPLE__)
+#define LLVM_SUPPORT_XCODE_SIGNPOSTS 1
+#else
#define LLVM_SUPPORT_XCODE_SIGNPOSTS 0
+#endif
#endif
diff --git a/lib/clang/llvm.build.mk b/lib/clang/llvm.build.mk
index b248fb816364..9f13ae5aa3ff 100644
--- a/lib/clang/llvm.build.mk
+++ b/lib/clang/llvm.build.mk
@@ -100,7 +100,11 @@ CFLAGS+= -DLLVM_NATIVE_TARGETMC=LLVMInitialize${LLVM_NATIVE_ARCH}TargetMC
CFLAGS+= -ffunction-sections
CFLAGS+= -fdata-sections
+.if ${LINKER_TYPE} == "mac"
+LDFLAGS+= -Wl,-dead_strip
+.else
LDFLAGS+= -Wl,--gc-sections
+.endif
CXXSTD?= c++14
CXXFLAGS+= -fno-exceptions
diff --git a/usr.bin/clang/clang.prog.mk b/usr.bin/clang/clang.prog.mk
index de5cceac7c6b..af28af3a4f85 100644
--- a/usr.bin/clang/clang.prog.mk
+++ b/usr.bin/clang/clang.prog.mk
@@ -17,8 +17,14 @@ LDADD+= ${OBJTOP}/lib/clang/lib${lib}/lib${lib}.a
PACKAGE= clang
+.if ${.MAKE.OS} == "FreeBSD" || !defined(BOOTSTRAPPING)
LIBADD+= execinfo
+.endif
+.if ${.MAKE.OS} == "FreeBSD" || !defined(BOOTSTRAPPING)
LIBADD+= ncursesw
+.elif ${.MAKE.OS} == "Linux"
+LDFLAGS+= -ltinfo
+.endif
LIBADD+= pthread
.include <bsd.prog.mk>
diff --git a/usr.bin/clang/lld/Makefile b/usr.bin/clang/lld/Makefile
index 3593a4006ba2..1af65c29b160 100644
--- a/usr.bin/clang/lld/Makefile
+++ b/usr.bin/clang/lld/Makefile
@@ -102,8 +102,14 @@ TGHDRS+= ${INCFILE}
DPSRCS+= ${TGHDRS}
CLEANFILES+= ${TGHDRS} ${TGHDRS:C/$/.d/}
+.if ${.MAKE.OS} == "FreeBSD" || !defined(BOOTSTRAPPING)
LIBADD+= execinfo
+.endif
+.if ${.MAKE.OS} == "FreeBSD" || !defined(BOOTSTRAPPING)
LIBADD+= ncursesw
+.elif ${.MAKE.OS} == "Linux"
+LDFLAGS+= -ltinfo
+.endif
LIBADD+= pthread
LIBADD+= z
diff --git a/usr.bin/clang/lldb-server/Makefile b/usr.bin/clang/lldb-server/Makefile
index 28e0c4ce7260..5787df0cc13b 100644
--- a/usr.bin/clang/lldb-server/Makefile
+++ b/usr.bin/clang/lldb-server/Makefile
@@ -42,10 +42,16 @@ DPSRCS+= ${TGHDRS}
CLEANFILES+= ${TGHDRS} ${TGHDRS:C/$/.d/}
LIBADD+= edit
+.if ${.MAKE.OS} == "FreeBSD" || !defined(BOOTSTRAPPING)
LIBADD+= execinfo
+.endif
LIBADD+= lua
LIBADD+= lzma
+.if ${.MAKE.OS} == "FreeBSD" || !defined(BOOTSTRAPPING)
LIBADD+= ncursesw
+.elif ${.MAKE.OS} == "Linux"
+LDFLAGS+= -ltinfo
+.endif
LIBADD+= panel
LIBADD+= pthread
LIBADD+= z
diff --git a/usr.bin/clang/lldb/Makefile b/usr.bin/clang/lldb/Makefile
index c309559b06e7..57dfe19ce585 100644
--- a/usr.bin/clang/lldb/Makefile
+++ b/usr.bin/clang/lldb/Makefile
@@ -35,10 +35,16 @@ DPSRCS+= ${TGHDRS}
CLEANFILES+= ${TGHDRS} ${TGHDRS:C/$/.d/}
LIBADD+= edit
+.if ${.MAKE.OS} == "FreeBSD" || !defined(BOOTSTRAPPING)
LIBADD+= execinfo
+.endif
LIBADD+= lua
LIBADD+= lzma
+.if ${.MAKE.OS} == "FreeBSD" || !defined(BOOTSTRAPPING)
LIBADD+= ncursesw
+.elif ${.MAKE.OS} == "Linux"
+LDFLAGS+= -ltinfo
+.endif
LIBADD+= panel
LIBADD+= pthread
LIBADD+= z
diff --git a/usr.bin/clang/llvm.prog.mk b/usr.bin/clang/llvm.prog.mk
index 58fd3eedd113..3944671222c5 100644
--- a/usr.bin/clang/llvm.prog.mk
+++ b/usr.bin/clang/llvm.prog.mk
@@ -22,8 +22,14 @@ LDADD+= ${OBJTOP}/lib/clang/lib${lib}/lib${lib}.a
PACKAGE= clang
+.if ${.MAKE.OS} == "FreeBSD" || !defined(BOOTSTRAPPING)
LIBADD+= execinfo
+.endif
+.if ${.MAKE.OS} == "FreeBSD" || !defined(BOOTSTRAPPING)
LIBADD+= ncursesw
+.elif ${.MAKE.OS} == "Linux"
+LDFLAGS+= -ltinfo
+.endif
LIBADD+= pthread
.include <bsd.prog.mk>