Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src-draft/trunk]: src/tools/llvm-lib Check if C++ modules are supported and ...
details: https://anonhg.NetBSD.org/src-all/rev/1d6009d0faf2
branches: trunk
changeset: 931817:1d6009d0faf2
user: Joerg Sonnenberger <joerg%bec.de@localhost>
date: Mon Apr 20 23:33:29 2020 +0200
description:
Check if C++ modules are supported and build LLVM with them if possible
This speeds up a release build with clang and X11 enabled by 15%.
Downside is that the cache has to be explicitely purged on every build
as it doesn't deal well with changes. Do this during the depends phase.
diffstat:
external/apache2/llvm/Makefile.inc | 12 ++++++++++++
external/apache2/llvm/config/llvm/module.modulemap | 13 +++++++++++++
external/apache2/llvm/include/Makefile | 6 ++++++
external/apache2/llvm/include/module.modulemap | 13 +++++++++++++
external/apache2/llvm/librt/Makefile.inc | 3 +++
tools/llvm-lib/Makefile | 2 ++
tools/llvm/Makefile | 22 ++++++++++++++++++----
tools/llvm/module-test.cpp | 14 ++++++++++++++
8 files changed, 81 insertions(+), 4 deletions(-)
diffs (176 lines):
diff -r c8b365db2101 -r 1d6009d0faf2 external/apache2/llvm/Makefile.inc
--- a/external/apache2/llvm/Makefile.inc Sat Apr 25 21:27:37 2020 +0200
+++ b/external/apache2/llvm/Makefile.inc Mon Apr 20 23:33:29 2020 +0200
@@ -22,20 +22,32 @@
# Bogus warning with -O2 in GCC 7 and 8.
CWARNFLAGS.gcc+= ${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} < 9:? -Wno-stringop-overflow :}
+MODULES_CXXFLAGS= -fmodules -fcxx-modules -Werror=incomplete-umbrella \
+ -fmodules-validate-system-headers \
+ -Xclang -fmodules-local-submodule-visibility \
+ -fmodules-cache-path=${LLVM_MODULE_CACHE:Q}
+
.if defined(HOSTLIB) || defined(HOSTPROG) || defined(_BSD_HOSTINIT_MK_)
LLVM_INCLUDE_CONFIG= ${LLVM_TOOLCONF_OBJDIR}/config/include
CLANG_INCLUDE_CONFIG= ${LLVM_TOOLCONF_OBJDIR}/config/tools/clang/include
LLVM_INCLUDE_OBJDIR!= cd ${NETBSDSRCDIR}/tools/llvm-include && ${PRINTOBJDIR}
LLVM_TOOLCONF_OBJDIR!= cd ${NETBSDSRCDIR}/tools/llvm && ${PRINTOBJDIR}
+LLVM_MODULE_CACHE= ${LLVM_TOOLCONF_OBJDIR}/module.cache
HOST_CPPFLAGS+= ${CPPFLAGS}
HOST_CXXFLAGS+= -O2 -fno-rtti -fno-exceptions -fno-strict-aliasing
+.sinclude "${LLVM_TOOLCONF_OBJDIR}/support-modules"
+.if ${HOST_SUPPORTS_MODULES:Uno} == "yes"
+HOST_CXXFLAGS+= ${MODULES_CXXFLAGS}
+.endif
HOST_CPPFLAGS+= -std=c++14
LLVM_TARGETS= x86,powerpc,sparc,aarch64,arm,mips
.else
LLVM_INCLUDE_CONFIG= ${LLVM_TOPLEVEL}/config
CLANG_INCLUDE_CONFIG= ${LLVM_TOPLEVEL}/config
LLVM_INCLUDE_OBJDIR!= cd ${LLVM_TOPLEVEL}/include && ${PRINTOBJDIR}
+LLVM_MODULE_CACHE= ${LLVM_INCLUDE_OBJDIR}/module.cache
LLVM_TARGETS= x86,powerpc,sparc,aarch64,arm,mips,amdgpu
+CXXFLAGS+= ${${ACTIVE_CC} == "clang":? ${MODULES_CXXFLAGS} :}
CXXFLAGS+= -std=c++14
CXXFLAGS+= -fno-rtti -fno-exceptions ${${ACTIVE_CC} == "gcc" :? -fno-strict-aliasing :}
diff -r c8b365db2101 -r 1d6009d0faf2 external/apache2/llvm/config/llvm/module.modulemap
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/external/apache2/llvm/config/llvm/module.modulemap Mon Apr 20 23:33:29 2020 +0200
@@ -0,0 +1,13 @@
+// This is copied into the build area for a $src != $build compilation.
+module LLVM_Support_DataTypes {
+ header "Support/DataTypes.h"
+ export *
+}
+module LLVM_Config_ABI_Breaking {
+ header "Config/abi-breaking.h"
+ export *
+}
+module LLVM_Config_Config {
+ header "Config/llvm-config.h"
+ export *
+}
diff -r c8b365db2101 -r 1d6009d0faf2 external/apache2/llvm/include/Makefile
--- a/external/apache2/llvm/include/Makefile Sat Apr 25 21:27:37 2020 +0200
+++ b/external/apache2/llvm/include/Makefile Mon Apr 20 23:33:29 2020 +0200
@@ -412,6 +412,7 @@
rm -r tmp
mv ${LLVM_INCLUDE_CONFIG}/llvm/Config/config.h \
${LLVM_INCLUDE_CONFIG}/llvm/Config/config.h.in
+ cp ${.CURDIR}/module.modulemap ${LLVM_INCLUDE_CONFIG}/llvm/module.modulemap
.endif
DPSRCS+= llvm/Support/Extension.def
@@ -423,4 +424,9 @@
includes depend dependall all: ${DPSRCS}
+dependall: clean-modulecache
+
+clean-modulecache:
+ rm -rf ${LLVM_MODULE_CACHE}
+
.include <bsd.prog.mk>
diff -r c8b365db2101 -r 1d6009d0faf2 external/apache2/llvm/include/module.modulemap
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/external/apache2/llvm/include/module.modulemap Mon Apr 20 23:33:29 2020 +0200
@@ -0,0 +1,13 @@
+// This is copied into the build area for a $src != $build compilation.
+module LLVM_Support_DataTypes {
+ header "Support/DataTypes.h"
+ export *
+}
+module LLVM_Config_ABI_Breaking {
+ header "Config/abi-breaking.h"
+ export *
+}
+module LLVM_Config_Config {
+ header "Config/llvm-config.h"
+ export *
+}
diff -r c8b365db2101 -r 1d6009d0faf2 external/apache2/llvm/librt/Makefile.inc
--- a/external/apache2/llvm/librt/Makefile.inc Sat Apr 25 21:27:37 2020 +0200
+++ b/external/apache2/llvm/librt/Makefile.inc Mon Apr 20 23:33:29 2020 +0200
@@ -5,3 +5,6 @@
.include "${LLVM_TOPLEVEL}/lib/Makefile.inc"
.include "${LLVM_TOPLEVEL}/lib/${.CURDIR:T}/Makefile"
+
+LLVM_INCLUDE_OBJDIR!= cd ${LLVM_TOPLEVEL}/include && ${PRINTOBJDIR}
+LLVM_MODULE_CACHE= ${LLVM_INCLUDE_OBJDIR}/module.cache-rt
diff -r c8b365db2101 -r 1d6009d0faf2 tools/llvm-lib/Makefile
--- a/tools/llvm-lib/Makefile Sat Apr 25 21:27:37 2020 +0200
+++ b/tools/llvm-lib/Makefile Mon Apr 20 23:33:29 2020 +0200
@@ -4,6 +4,8 @@
NO_LLVM_DEVELOPER= yes
+all: depend
+
.include "${.PARSEDIR}/../llvm/Makefile.inc"
.include "${LLVM_TOPLEVEL}/lib/Makefile"
diff -r c8b365db2101 -r 1d6009d0faf2 tools/llvm/Makefile
--- a/tools/llvm/Makefile Sat Apr 25 21:27:37 2020 +0200
+++ b/tools/llvm/Makefile Mon Apr 20 23:33:29 2020 +0200
@@ -9,7 +9,12 @@
.include "Makefile.inc"
.include "${LLVM_TOPLEVEL}/lib/Makefile.inc"
-realdepends realall: config/config.status need-dl need-terminfo
+realdepends realall: config/config.status need-dl need-terminfo support-modules
+
+dependall: clean-modulecache
+
+clean-modulecache:
+ rm -rf ${LLVM_MODULE_CACHE}
config/config.status: ${LLVM_SRCDIR}/configure
mkdir -p config
@@ -17,8 +22,16 @@
chmod 755 config/python
cd config && ${HOST_SH} ${CONFIG_DIR}/configure ${LLVM_CONFIGURE_ARGS} \
--enable-optimized CC=${HOST_CC:Q} CXX=${HOST_CXX:Q} \
- --with-python=${.OBJDIR}/config/python
-# --disable-assertions
+ --with-python=${.OBJDIR}/config/python && \
+ cp ${LLVM_TOPLEVEL}/include/module.modulemap include/llvm/module.modulemap
+
+support-modules: module-test.cpp Makefile
+ if ${HOST_CXX} -stdlib=libc++ -c -fmodules -fcxx-modules -fmodules-cache-path=./module.cache \
+ ${.CURDIR}/module-test.cpp 3> /dev/null 2>&1; then \
+ echo HOST_SUPPORTS_MODULES=yes > ${.TARGET}; \
+ else \
+ echo HOST_SUPPORTS_MODULES=no > ${.TARGET}; \
+ fi
need-dl: Makefile
printf '#include <dlfcn.h>\nint main(void){void *p; return dladdr(p, p);}' > need-dl.c
@@ -45,6 +58,7 @@
cleandir-llvm: .PHONY
test ! -d config || rm -r config
- rm -f need-dl need-dl.tmp
+ test ! -d module-cache || rm -r module-cache
+ rm -f need-dl need-dl.tmp module-cache module-test.o
.include <bsd.hostprog.mk>
diff -r c8b365db2101 -r 1d6009d0faf2 tools/llvm/module-test.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/llvm/module-test.cpp Mon Apr 20 23:33:29 2020 +0200
@@ -0,0 +1,14 @@
+// Test that NDEBUG works
+#undef NDEBUG
+#include <cassert>
+#define NDEBUG
+#include <cassert>
+int
+main()
+{
+ assert(this code is not compiled);
+}
+
+#ifndef _LIBCPP_VERSION
+#error "Modules currently requires libc++"
+#endif
Home |
Main Index |
Thread Index |
Old Index