Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F153467416
D31057.id92431.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
11 KB
Referenced Files
None
Subscribers
None
D31057.id92431.diff
View Options
Index: contrib/llvm-project/lld/tools/lld/lld.cpp
===================================================================
--- contrib/llvm-project/lld/tools/lld/lld.cpp
+++ contrib/llvm-project/lld/tools/lld/lld.cpp
@@ -146,7 +146,8 @@
static int lldMain(int argc, const char **argv, llvm::raw_ostream &stdoutOS,
llvm::raw_ostream &stderrOS, bool exitEarly = true) {
std::vector<const char *> args(argv, argv + argc);
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(LLVM_BOOTSTRAPPING)
+ /* On FreeBSD we only build the ELF linker. */
return !elf::link(args, exitEarly, stdoutOS, stderrOS);
#else
switch (parseFlavor(args)) {
Index: lib/clang/include/llvm/Config/config.h
===================================================================
--- lib/clang/include/llvm/Config/config.h
+++ 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 __has_include(<link.h>)
#define HAVE_LINK_H 1
+#else
+#define HAVE_LINK_H 0
+#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 __has_include(<mach/mach.h>)
+#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 __has_include(<malloc/malloc.h>)
+#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,31 @@
#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(LLVM_BOOTSTRAPPING)
+/*
+ * This is only needed for terminalHasColors(). When disabled LLVM falls back
+ * to checking a list of TERM prefixes which is sufficient for a bootstrap tool.
+ */
#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
+#endif
/* Define to 1 if you have the <termios.h> header file. */
#define HAVE_TERMIOS_H 1
@@ -239,7 +273,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 +351,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 +391,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
Index: lib/clang/libllvm/Makefile
===================================================================
--- lib/clang/libllvm/Makefile
+++ lib/clang/libllvm/Makefile
@@ -717,7 +717,8 @@
SRCS_EXL+= LTO/SummaryBasedOptimizations.cpp
SRCS_EXL+= LTO/ThinLTOCodeGenerator.cpp
SRCS_MIN+= LTO/UpdateCompilerUsed.cpp
-SRCS_MIN+= LineEditor/LineEditor.cpp
+# Only needed for clangd/clang-query
+# SRCS_XDW+= LineEditor/LineEditor.cpp
SRCS_MIN+= Linker/IRMover.cpp
SRCS_MIN+= Linker/LinkModules.cpp
SRCS_MIN+= MC/ConstantPools.cpp
Index: lib/clang/llvm.build.mk
===================================================================
--- lib/clang/llvm.build.mk
+++ lib/clang/llvm.build.mk
@@ -100,12 +100,24 @@
CFLAGS+= -ffunction-sections
CFLAGS+= -fdata-sections
+.include <bsd.linker.mk>
+.if ${LINKER_TYPE} == "mac"
+LDFLAGS+= -Wl,-dead_strip
+.else
LDFLAGS+= -Wl,--gc-sections
+.endif
CXXSTD?= c++14
CXXFLAGS+= -fno-exceptions
CXXFLAGS+= -fno-rtti
+.if defined(BOOTSTRAPPING)
+CFLAGS+= -DLLVM_BOOTSTRAPPING
+.else
CXXFLAGS.clang+= -stdlib=libc++
+.endif
+.if defined(BOOTSTRAPPING) && ${.MAKE.OS} == "Linux"
+LIBADD+= dl
+.endif
.if ${MACHINE_ARCH:Mmips64}
STATIC_CFLAGS+= -mxgot
Index: lib/libc/db/db/db.c
===================================================================
--- lib/libc/db/db/db.c
+++ lib/libc/db/db/db.c
@@ -55,20 +55,26 @@
{
#define DB_FLAGS (DB_LOCK | DB_SHMEM | DB_TXN)
-#define USE_OPEN_FLAGS \
- (O_CREAT | O_EXCL | O_EXLOCK | O_NOFOLLOW | O_NONBLOCK | \
- O_RDONLY | O_RDWR | O_SHLOCK | O_SYNC | O_TRUNC | O_CLOEXEC)
+ const int use_open_flags = O_CREAT | O_EXCL | O_NOFOLLOW | O_NONBLOCK |
+ O_RDONLY | O_RDWR | O_SYNC | O_TRUNC |
+#ifdef O_EXLOCK
+ O_EXLOCK |
+#endif
+#ifdef O_SHLOCK
+ O_SHLOCK |
+#endif
+ O_CLOEXEC;
- if ((flags & ~(USE_OPEN_FLAGS | DB_FLAGS)) == 0)
+ if ((flags & ~(use_open_flags | DB_FLAGS)) == 0)
switch (type) {
case DB_BTREE:
- return (__bt_open(fname, flags & USE_OPEN_FLAGS,
+ return (__bt_open(fname, flags & use_open_flags,
mode, openinfo, flags & DB_FLAGS));
case DB_HASH:
- return (__hash_open(fname, flags & USE_OPEN_FLAGS,
+ return (__hash_open(fname, flags & use_open_flags,
mode, openinfo, flags & DB_FLAGS));
case DB_RECNO:
- return (__rec_open(fname, flags & USE_OPEN_FLAGS,
+ return (__rec_open(fname, flags & use_open_flags,
mode, openinfo, flags & DB_FLAGS));
}
errno = EINVAL;
Index: share/mk/src.opts.mk
===================================================================
--- share/mk/src.opts.mk
+++ share/mk/src.opts.mk
@@ -360,14 +360,6 @@
__DEFAULT_NO_OPTIONS+=OPENMP
.endif
-.if ${.MAKE.OS} != "FreeBSD"
-# Building the target compiler requires building tablegen on the host
-# which is (currently) not possible on non-FreeBSD.
-BROKEN_OPTIONS+=CLANG LLD LLDB
-# The same also applies to the bootstrap LLVM.
-BROKEN_OPTIONS+=CLANG_BOOTSTRAP LLD_BOOTSTRAP
-.endif
-
.include <bsd.mkopt.mk>
#
Index: tools/build/cross-build/include/common/sys/sysctl.h
===================================================================
--- tools/build/cross-build/include/common/sys/sysctl.h
+++ tools/build/cross-build/include/common/sys/sysctl.h
@@ -37,6 +37,11 @@
*/
#pragma once
+#ifdef LLVM_BOOTSTRAPPING
+/* We need the real sysctl.h when bootstrapping LLVM tools. */
+#include_next <sys/sysctl.h>
+#else
+/* Otherwise, avoid sysctls since they might not be supported on the host. */
#include <sys/types.h>
#define sysctlbyname __freebsd_sysctlbyname
@@ -44,3 +49,4 @@
int sysctl(const int *, u_int, void *, size_t *, const void *, size_t);
int sysctlbyname(const char *, void *, size_t *, const void *, size_t);
+#endif
Index: tools/build/cross-build/include/linux/fcntl.h
===================================================================
--- tools/build/cross-build/include/linux/fcntl.h
+++ tools/build/cross-build/include/linux/fcntl.h
@@ -1,7 +1,7 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
- * Copyright 2018-2020 Alex Richardson <arichardson@FreeBSD.org>
+ * Copyright 2018-2021 Alex Richardson <arichardson@FreeBSD.org>
*
* This software was developed by SRI International and the University of
* Cambridge Computer Laboratory (Department of Computer Science and
@@ -12,6 +12,9 @@
* Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
* ("CTSRD"), as part of the DARPA CRASH research programme.
*
+ * This work was supported by Innovate UK project 105694, "Digital Security by
+ * Design (DSbD) Technology Platform Prototype".
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -37,29 +40,9 @@
*/
#pragma once
-
/* <bits/fcntl.h> includes <bits/stat.h> which contains a member __unused */
#include "__unused_workaround_start.h"
#include_next <fcntl.h>
#include "__unused_workaround_end.h"
-#ifdef __unused_undefd
-#undef __unused_undefd
-#define __unused __attribute__((unused))
-#endif
-
#include <sys/file.h>
-
-#ifndef O_EXLOCK
-#define O_EXLOCK (1 << 30)
-#endif
-#ifndef O_SHLOCK
-#define O_SHLOCK (1 << 31)
-#endif
-
-#undef open
-#define open(path, flags, ...) ({ \
- int __fd = (open)(path, flags, ##__VA_ARGS__); \
- if (flags & O_EXLOCK) flock(__fd, LOCK_EX); \
- if (flags & O_SHLOCK) flock(__fd, LOCK_SH); \
- __fd; })
Index: tools/build/make.py
===================================================================
--- tools/build/make.py
+++ tools/build/make.py
@@ -166,6 +166,9 @@
"needed if CC/CPP/CXX are not set). ")
parser.add_argument("--debug", action="store_true",
help="Print information on inferred env vars")
+ parser.add_argument("--bootstrap-toolchain", action="store_true",
+ help="Bootstrap the toolchain instead of using an "
+ "external one (experimetal and not recommended)")
parser.add_argument("--clean", action="store_true",
help="Do a clean rebuild instead of building with "
"-DWITHOUT_CLEAN")
@@ -195,6 +198,7 @@
if "universe" not in sys.argv and "tinderbox" not in sys.argv:
sys.exit("TARGET= and TARGET_ARCH= must be set explicitly "
"when building on non-FreeBSD")
+ if not parsed_args.bootstrap_toolchain:
# infer values for CC/CXX/CPP
if parsed_args.host_compiler_type == "gcc":
default_cc, default_cxx, default_cpp = ("gcc", "g++", "cpp")
Index: usr.bin/clang/clang.prog.mk
===================================================================
--- usr.bin/clang/clang.prog.mk
+++ usr.bin/clang/clang.prog.mk
@@ -17,8 +17,12 @@
PACKAGE= clang
+.if ${.MAKE.OS} == "FreeBSD" || !defined(BOOTSTRAPPING)
LIBADD+= execinfo
+.endif
+.if !defined(BOOTSTRAPPING)
LIBADD+= ncursesw
+.endif
LIBADD+= pthread
.include <bsd.prog.mk>
Index: usr.bin/clang/lld/Makefile
===================================================================
--- usr.bin/clang/lld/Makefile
+++ usr.bin/clang/lld/Makefile
@@ -102,8 +102,12 @@
DPSRCS+= ${TGHDRS}
CLEANFILES+= ${TGHDRS} ${TGHDRS:C/$/.d/}
+.if ${.MAKE.OS} == "FreeBSD" || !defined(BOOTSTRAPPING)
LIBADD+= execinfo
+.endif
+.if !defined(BOOTSTRAPPING)
LIBADD+= ncursesw
+.endif
LIBADD+= pthread
LIBADD+= z
Index: usr.bin/clang/llvm.prog.mk
===================================================================
--- usr.bin/clang/llvm.prog.mk
+++ usr.bin/clang/llvm.prog.mk
@@ -22,8 +22,12 @@
PACKAGE= clang
+.if ${.MAKE.OS} == "FreeBSD" || !defined(BOOTSTRAPPING)
LIBADD+= execinfo
+.endif
+.if !defined(BOOTSTRAPPING)
LIBADD+= ncursesw
+.endif
LIBADD+= pthread
.include <bsd.prog.mk>
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Apr 22, 8:20 AM (16 h, 30 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
31964405
Default Alt Text
D31057.id92431.diff (11 KB)
Attached To
Mode
D31057: Allow bootstrapping llvm-tblgen on macOS and Linux
Attached
Detach File
Event Timeline
Log In to Comment