Skip to contentSkip to conversation

libcxx: new package

PATCH New Norbert Lange 2 participants 3 messages Jun 13, 2018 – Oct 22, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libcxx: new package

provides llvm's libc++ as package, probably needs some more work to
better fit into buildroots toolchain construction.

It should be build after the host-g++ and C-Library, but before any other packages and it does install a small script host/bin/<xa-y-z>-g++-libc++
to allow easy use.

For lowlevel language support ABI, it can be built with libstdc++ support library or its own libc++-abi.

the parent LLVM software needs to be available, apparently for a few tools. Its downloaded currently, as depending on host-llvm means this package has to be built - which takes forever.

In the future, a option could potentially compile
all C++ Packages with this library.

- depend on threading library if available?
(supposedly builds without)
- proper integration in toolchain step
- use libc++ for remaining packages

---
 package/Config.in                             |   1 +
 package/libcxx/Config.in                      |  29 +++++
 package/libcxx/g++-libc++.in                  |  16 +++
 package/libcxx/libcxx.hash                    |   7 ++
 package/libcxx/libcxx.mk                      | 108 ++++++++++++++++++
 ...i_fix_find_fpath_when_crosscompiling.patch |  27 +++++
 6 files changed, 188 insertions(+)
 create mode 100644 package/libcxx/Config.in
 create mode 100644 package/libcxx/g++-libc++.in
 create mode 100644 package/libcxx/libcxx.hash
 create mode 100644 package/libcxx/libcxx.mk
 create mode 100644 package/libcxx/libcxxabi_fix_find_fpath_when_crosscompiling.patch
package/Config.in +1 -0
index fcabed4fde..cda825612a 100644
@@ -1565,6 +1565,7 @@ menu "Other"
 	source "package/lightning/Config.in"
 	source "package/linux-pam/Config.in"
 	source "package/llvm/Config.in"
+	source "package/libcxx/Config.in"
 if BR2_PACKAGE_LINUX_PAM
 comment "linux-pam plugins"
 	source "package/libpam-radius-auth/Config.in"
package/libcxx/Config.in new file +29 -0
new file mode 100644
index 0000000000..f5ff911b6d
@@ -0,0 +1,29 @@
+config BR2_PACKAGE_LIBCXX
+	bool "libc++"
+	depends on BR2_INSTALL_LIBSTDCPP
+	help
+	  libc++ is a new implementation of the C++ standard library,
+	  targeting C++11 (and newer). Part of the LLVM Project.
+
+	  The LLVM Project is a collection of modular and reusable
+	  compiler and toolchain technologies.
+
+if BR2_PACKAGE_LIBCXX
+choice
+	prompt "libc++ abi support"
+	default BR2_PACKAGE_LIBCXX_ABI_SUPCXX
+	help
+	  Select the c++ abi support: libsupc++ (from gcc toolchain)
+	  or libc++-abi (from llvm).
+
+config BR2_PACKAGE_LIBCXX_ABI_SUPCXX
+	bool "libsupc++"
+
+config BR2_PACKAGE_LIBCXX_ABI_CXXABI
+	bool "libc++-abi"
+
+endchoice
+endif
+
+comment "libc++ needs a toolchain w/ C++"
+	depends on !BR2_INSTALL_LIBSTDCPP
package/libcxx/g++-libc++.in new file +16 -0
new file mode 100644
index 0000000000..db6d050a7c
@@ -0,0 +1,16 @@
+#!/bin/sh
+SCRIPTPATH=$(readlink -f "$(dirname "$0")")
+cxx_libs="-lc++ @link_abi@"
+c_libs="-lc @link_comrt@"
+pthread_libs="-lpthread $c_libs"
+
+libs="$cxx_libs $c_libs"
+
+for i; do
+    if test x"$i" = x"-pthread"; then
+        libs="$libs $pthread_libs"
+        break
+    fi
+done
+
+exec "$SCRIPTPATH"/@TARGET_CROSS at g++ -nodefaultlibs -nostdinc++ $libs -isystem"$SCRIPTPATH"/../../staging/usr/include/c++/v1 "$@"
package/libcxx/libcxx.hash new file +7 -0
new file mode 100644
index 0000000000..7d384365b6
@@ -0,0 +1,7 @@
+# locally calculated
+sha256  1ff53c915b4e761ef400b803f07261ade637b0c269d99569f18040f3dcee4408  llvm-6.0.0.src.tar.xz
+sha256  70931a87bde9d358af6cb7869e7535ec6b015f7e6df64def6d2ecdd954040dd9  libcxx-6.0.0.src.tar.xz
+sha256  91c6d9c5426306ce28d0627d6a4448e7d164d6a3f64b01cb1d196003b16d641b  libcxxabi-6.0.0.src.tar.xz
+
+
+sha256  c1938c0e9e90639d1e8f5a7f6bebaab83a3642e0ee44295a4c69934686d0bda8  LICENSE.TXT
package/libcxx/libcxx.mk new file +108 -0

108 lines not on this page · raw message

package/libcxx/libcxxabi_fix_find_fpath_when_crosscompiling.patch new file +27 -0
new file mode 100644
index 0000000000..2fd95178f7
@@ -0,0 +1,27 @@
+diff -burN libcxx-6.0.0.org/projects/libcxxabi/CMakeLists.txt libcxx-6.0.0/projects/libcxxabi/CMakeLists.txt
+--- libcxx-6.0.0.org/projects/libcxxabi/CMakeLists.txt	2018-06-12 14:26:05.184675501 +0200
++++ libcxx-6.0.0/projects/libcxxabi/CMakeLists.txt	2018-06-12 14:27:05.553370290 +0200
+@@ -115,6 +115,7 @@
+         ${CMAKE_BINARY_DIR}/${LIBCXXABI_LIBCXX_INCLUDES}
+         ${LIBCXXABI_LIBCXX_INCLUDE_DIRS}
+         ${LLVM_INCLUDE_DIR}/c++/v1
++  NO_CMAKE_FIND_ROOT_PATH
+   )
+
+ set(LIBCXXABI_LIBCXX_INCLUDES "${LIBCXXABI_LIBCXX_INCLUDES}" CACHE PATH
+@@ -127,6 +128,7 @@
+         ${LIBCXXABI_LIBCXX_INCLUDES}/../
+         ${LIBCXXABI_LIBCXX_SRC_DIRS}
+   NO_DEFAULT_PATH
++  NO_CMAKE_FIND_ROOT_PATH
+   )
+
+ if (LIBCXXABI_LIBCXX_PATH STREQUAL "LIBCXXABI_LIBCXX_PATH-NOTFOUND")
+@@ -425,6 +427,7 @@
+           ${LLVM_MAIN_SRC_DIR}/projects/libunwind/include
+           ${LLVM_MAIN_SRC_DIR}/runtimes/libunwind/include
+     NO_DEFAULT_PATH
++    NO_CMAKE_FIND_ROOT_PATH
+   )
+
+   if (LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL STREQUAL "LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL-NOTFOUND")

--
2.17.1

#1 lore raw

PATCH 1/1 libcxx: new package

Hi Norbert,

Le 13/06/2018 ? 16:14, Norbert Lange a ?crit?:

Quoted 8 lines

provides llvm's libc++ as package, probably needs some more work to
better fit into buildroots toolchain construction.

It should be build after the host-g++ and C-Library, but before any other packages and it does install a small script host/bin/<xa-y-z>-g++-libc++
to allow easy use.

You should take into account the external toolchain case.

Quoted 8 lines

For lowlevel language support ABI, it can be built with libstdc++ support library or its own libc++-abi.

the parent LLVM software needs to be available, apparently for a few tools. Its downloaded currently, as depending on host-llvm means this package has to be built - which takes forever.

By now, llvm package is merged and updated to llvm 7.0.
Can you try building libcxx as a standalone package (LIBCXX_STANDALONE_BUILD=ON) using the llvm package provided by Buildroot ?

Also libcxx and libcxxabi should be packaged separately.

Review

Quoted 8 lines

In the future, a option could potentially compile
all C++ Packages with this library.

(quoted diff) +0 -3
-   depend on threading library if available?
    (supposedly builds without)
-   proper integration in toolchain step
-   use libc++ for remaining packages

Also you can take a look at the report from the FOSDEM meeting and the final report from Valentin:
https://elinux.org/Buildroot:DeveloperDaysFOSDEM2018#LLVM.2FClang
http://www.linuxembedded.fr/2018/07/llvmclang-integration-into-buildroot

Quoted 34 lines
---
 package/Config.in                             |   1 +
 package/libcxx/Config.in                      |  29 +++++
 package/libcxx/g++-libc++.in                  |  16 +++
 package/libcxx/libcxx.hash                    |   7 ++
 package/libcxx/libcxx.mk                      | 108 ++++++++++++++++++
 ...i_fix_find_fpath_when_crosscompiling.patch |  27 +++++
 6 files changed, 188 insertions(+)
 create mode 100644 package/libcxx/Config.in
 create mode 100644 package/libcxx/g++-libc++.in
 create mode 100644 package/libcxx/libcxx.hash
 create mode 100644 package/libcxx/libcxx.mk
 create mode 100644 package/libcxx/libcxxabi_fix_find_fpath_when_crosscompiling.patch
package/Config.in +1 -0
index fcabed4fde..cda825612a 100644
@@ -1565,6 +1565,7 @@ menu "Other"
 	source "package/lightning/Config.in"
 	source "package/linux-pam/Config.in"
 	source "package/llvm/Config.in"
+	source "package/libcxx/Config.in"
 if BR2_PACKAGE_LINUX_PAM
 comment "linux-pam plugins"
 	source "package/libpam-radius-auth/Config.in"
package/libcxx/Config.in new file +0 -0
new file mode 100644
index 0000000000..f5ff911b6d

package/libcxx/Config.in line 3

Quoted 3 lines
package/libcxx/Config.in new file +3 -0
@@ -0,0 +1,29 @@
+config BR2_PACKAGE_LIBCXX
+	bool "libc++"
+	depends on BR2_INSTALL_LIBSTDCPP

C++ dependency is not enough for C++11 dependency, you should add a dependency on gcc >= 4.8 (at least).
Also add a dependency on llvm supported architectures.

package/libcxx/g++-libc++.in

Quoted 27 lines
package/libcxx/Config.in new file +26 -0
+	help
+	  libc++ is a new implementation of the C++ standard library,
+	  targeting C++11 (and newer). Part of the LLVM Project.
+
+	  The LLVM Project is a collection of modular and reusable
+	  compiler and toolchain technologies.
+
+if BR2_PACKAGE_LIBCXX
+choice
+	prompt "libc++ abi support"
+	default BR2_PACKAGE_LIBCXX_ABI_SUPCXX
+	help
+	  Select the c++ abi support: libsupc++ (from gcc toolchain)
+	  or libc++-abi (from llvm).
+
+config BR2_PACKAGE_LIBCXX_ABI_SUPCXX
+	bool "libsupc++"
+
+config BR2_PACKAGE_LIBCXX_ABI_CXXABI
+	bool "libc++-abi"
+
+endchoice
+endif
+
+comment "libc++ needs a toolchain w/ C++"
+	depends on !BR2_INSTALL_LIBSTDCPP
package/libcxx/g++-libc++.in +0 -0

What's the purpose of this script ?

Quoted 40 lines

new file mode 100644
index 0000000000..db6d050a7c

package/libcxx/g++-libc++.in new file +16 -0
@@ -0,0 +1,16 @@
+#!/bin/sh
+SCRIPTPATH=$(readlink -f "$(dirname "$0")")
+cxx_libs="-lc++ @link_abi@"
+c_libs="-lc @link_comrt@"
+pthread_libs="-lpthread $c_libs"
+
+libs="$cxx_libs $c_libs"
+
+for i; do
+    if test x"$i" = x"-pthread"; then
+        libs="$libs $pthread_libs"
+        break
+    fi
+done
+
+exec "$SCRIPTPATH"/@TARGET_CROSS at g++ -nodefaultlibs -nostdinc++ $libs -isystem"$SCRIPTPATH"/../../staging/usr/include/c++/v1 "$@"
package/libcxx/libcxx.hash new file +7 -0
new file mode 100644
index 0000000000..7d384365b6
@@ -0,0 +1,7 @@
+# locally calculated
+sha256  1ff53c915b4e761ef400b803f07261ade637b0c269d99569f18040f3dcee4408  llvm-6.0.0.src.tar.xz
+sha256  70931a87bde9d358af6cb7869e7535ec6b015f7e6df64def6d2ecdd954040dd9  libcxx-6.0.0.src.tar.xz
+sha256  91c6d9c5426306ce28d0627d6a4448e7d164d6a3f64b01cb1d196003b16d641b  libcxxabi-6.0.0.src.tar.xz
+
+
+sha256  c1938c0e9e90639d1e8f5a7f6bebaab83a3642e0ee44295a4c69934686d0bda8  LICENSE.TXT
package/libcxx/libcxx.mk new file +0 -0
new file mode 100644
index 0000000000..9d9efc90b0

package/libcxx/libcxx.mk line 7

Quoted 7 lines
package/libcxx/libcxx.mk new file +7 -0
@@ -0,0 +1,108 @@
+################################################################################
+#
+# libc++
+#
+################################################################################
+
+LIBCXX_VERSION = 6.0.0

Can you try with 7.0.0 version ?

package/libcxx/libcxx.mk line 15

Quoted 8 lines
package/libcxx/libcxx.mk new file +8 -0
+LIBCXX_SITE = http://llvm.org/releases/$(LIBCXX_VERSION)
+LIBCXX_SOURCE = llvm-$(LIBCXX_VERSION).src.tar.xz
+LIBCXX_LICENSE = MIT
+#LIBCXX_LICENSE_FILES = COPYRIGHT
+LIBCXX_SUPPORTS_IN_SOURCE_BUILD = NO
+LIBCXX_INSTALL_STAGING = YES
+
+LIBCXX_EXTRA_DOWNLOADS = $(patsubst %,$(LIBCXX_SITE)/%-$(LIBCXX_VERSION).src.tar.xz,libcxx libcxxabi)

Can you try to package libcxx and libcxxabi separately ?

package/libcxx/libcxxabi_fix_find_fpath_when_crosscompiling.patch

Quoted 97 lines
package/libcxx/libcxx.mk new file +92 -0
+
+define LIBCXX_EXTRA_EXTRACT
+	$(foreach arch,$(LIBCXX_EXTRA_DOWNLOADS), \
+		TDIR=projects/$(patsubst $(LIBCXX_SITE)/%-$(LIBCXX_VERSION).src.tar.xz,%,$(arch)); \
+		mkdir -p $(@D)/$$TDIR && \
+		$(call suitable-extractor,$(notdir $(arch))) $(LIBCXX_DL_DIR)/$(notdir $(arch)) | \
+		$(TAR) --strip-components=1 -C $(@D)/$$TDIR $(TAR_OPTIONS) -
+	)
+endef> +
+LIBCXX_POST_EXTRACT_HOOKS += LIBCXX_EXTRA_EXTRACT
+
+# Before libcxx is configured, we must have the first stage
+# cross-compiler and the clibrary
+LIBCXX_DEPENDENCIES = host-gcc-initial
+
+ifeq ($(BR2_PACKAGE_LIBCXX_ABI_CXXABI),y)
+_LIBCXX_ABI_TARGET = cxxabi
+endif
+
+_LIBCXX_ABI-$(BR2_PACKAGE_LIBCXX_ABI_CXXABI) = libcxxabi
+_LIBCXX_ABI-$(BR2_PACKAGE_LIBCXX_ABI_SUPCXX) = libsupc++
+
+_LIBCXX_ABI_LINK-$(BR2_PACKAGE_LIBCXX_ABI_CXXABI) = c++abi
+_LIBCXX_ABI_LINK-$(BR2_PACKAGE_LIBCXX_ABI_SUPCXX) = supc++
+
+LIBCXX_MAKE_OPTS = $(_LIBCXX_ABI_TARGET) cxx
+
+LIBCXX_INSTALL_STAGING_OPTS = DESTDIR=$(STAGING_DIR) $(addprefix install-,$(_LIBCXX_ABI_TARGET) cxx)
+
+LIBCXX_INSTALL_TARGET_OPTS = DESTDIR=$(TARGET_DIR) $(addprefix install-,$(_LIBCXX_ABI_TARGET) cxx)
+
+
+#LIBCXXABI_SYSROOT LIBCXX_SYSROOT
+# TODO: potentially depend on threading library?
+# allow using gccs libsupc++
+# consider whether its better to statically link libc++-abi
+# USe this library to build the remaining C++ packages?
+
+# llvm does not recommend using this
+LIBCXX_CONF_OPTS += -DBUILD_SHARED_LIBS:BOOL=OFF
+
+LIBCXX_CONF_OPTS += -DLIBCXXABI_INCLUDE_TESTS=OFF -DLIBCXXABI_ENABLE_ASSERTIONS=OFF -DLIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS=OFF -DLIBCXX_ENABLE_NEW_DELETE_DEFINITIONS=ON
+
+ifeq ($(BR2_TOOLCHAIN_USES_MUSL),y)
+LIBCXX_CONF_OPTS += -DLIBCXX_HAS_MUSL_LIBC:BOOL=ON
+endif
+
+ifeq ($(BR2_SHARED_LIBS)$(BR2_SHARED_STATIC_LIBS),y)
+LIBCXX_CONF_OPTS += -DLIBCXXABI_ENABLE_SHARED:BOOL=ON -DLIBCXX_ENABLE_SHARED:BOOL=ON
+else
+LIBCXX_CONF_OPTS += -DLIBCXXABI_ENABLE_SHARED:BOOL=OFF -DLIBCXX_ENABLE_SHARED:BOOL=OFF
+endif
+
+ifeq ($(BR2_STATIC_LIBS)$(BR2_SHARED_STATIC_LIBS),y)
+LIBCXX_CONF_OPTS += -DLIBCXXABI_ENABLE_STATIC:BOOL=ON -DLIBCXX_ENABLE_STATIC:BOOL=ON
+else
+LIBCXX_CONF_OPTS += -DLIBCXXABI_ENABLE_STATIC:BOOL=OFF -DLIBCXX_ENABLE_STATIC:BOOL=OFF
+endif
+
+LIBCXX_CONF_OPTS += -DLIBCXX_ENABLE_ABI_LINKER_SCRIPT=ON
+
+#LIBCXX_CONF_OPTS += -DLLVM_PATH:PATH=$(@D)/llvm
+
+#LIBCXX_CONF_OPTS += -DLIBCXX_CXX_ABI:STRING=default
+
+# libc++ needs to be massaged to pick header and libs
+LIBCXX_CONF_OPTS += -DLIBCXX_CXX_ABI:STRING=$(_LIBCXX_ABI-y)
+
+ifneq ($(_LIBCXX_ABI_TARGET),)
+LIBCXX_CONF_OPTS += -DLIBCXX_CXX_ABI_INCLUDE_PATHS:PATH=$(@D)/projects/libcxxabi/include \
+					-DLIBCXX_CXX_ABI_LIBRARY_PATH:PATH=../../../lib
+endif
+
+
+#LIBCXX_CONF_OPTS += -DLIBCXX_INCLUDE_BENCHMARKS:BOOL=OFF
+#LIBCXX_CONF_OPTS += -DLIBCXX_INCLUDE_DOCS:BOOL=OFF
+#LIBCXX_CONF_OPTS += -DLIBCXX_INCLUDE_TESTS:BOOL=OFF
+
+cxx_libs="-lc++ @link_abi@"
+c_libs="-lc @link_comrt@"
+
+# Create a g++ wrapper to add the necessary aguments for building with libc++
+define LIBCXX_CREATE_GXXWRAPPER_TARGET
+	sed -e 's, at TARGET_CROSS@,$(notdir $(TARGET_CROSS)),g' \
+	  -e 's, at link_abi@,$(addprefix -l,$(_LIBCXX_ABI_LINK-y)),g' \
+	  -e 's, at link_comrt@,-lgcc_s,g' \
+	  $(LIBCXX_PKGDIR)g++-libc++.in > $(LIBCXX_BUILDDIR)gxxwrap.tmp
+	install -D -m755 $(LIBCXX_BUILDDIR)gxxwrap.tmp $(TARGET_CROSS)g++-libc++
+endef
+LIBCXX_POST_INSTALL_TARGET_HOOKS = LIBCXX_CREATE_GXXWRAPPER_TARGET
+
+$(eval $(cmake-package))
package/libcxx/libcxxabi_fix_find_fpath_when_crosscompiling.patch new file +0 -0
new file mode 100644
index 0000000000..2fd95178f7

Please, provide a patch generated with git format-patch with a commit log, upstream status and you SoB line.

I'll mark you patch "Change Requested" in the patchwork, please send an updated version.

Best regards,
Romain

Quoted 36 lines
package/libcxx/libcxxabi_fix_find_fpath_when_crosscompiling.patch new file +27 -1
@@ -0,0 +1,27 @@
+diff -burN libcxx-6.0.0.org/projects/libcxxabi/CMakeLists.txt libcxx-6.0.0/projects/libcxxabi/CMakeLists.txt
+--- libcxx-6.0.0.org/projects/libcxxabi/CMakeLists.txt	2018-06-12 14:26:05.184675501 +0200
++++ libcxx-6.0.0/projects/libcxxabi/CMakeLists.txt	2018-06-12 14:27:05.553370290 +0200
+@@ -115,6 +115,7 @@
+         ${CMAKE_BINARY_DIR}/${LIBCXXABI_LIBCXX_INCLUDES}
+         ${LIBCXXABI_LIBCXX_INCLUDE_DIRS}
+         ${LLVM_INCLUDE_DIR}/c++/v1
++  NO_CMAKE_FIND_ROOT_PATH
+   )
+
+ set(LIBCXXABI_LIBCXX_INCLUDES "${LIBCXXABI_LIBCXX_INCLUDES}" CACHE PATH
+@@ -127,6 +128,7 @@
+         ${LIBCXXABI_LIBCXX_INCLUDES}/../
+         ${LIBCXXABI_LIBCXX_SRC_DIRS}
+   NO_DEFAULT_PATH
++  NO_CMAKE_FIND_ROOT_PATH
+   )
+
+ if (LIBCXXABI_LIBCXX_PATH STREQUAL "LIBCXXABI_LIBCXX_PATH-NOTFOUND")
+@@ -425,6 +427,7 @@
+           ${LLVM_MAIN_SRC_DIR}/projects/libunwind/include
+           ${LLVM_MAIN_SRC_DIR}/runtimes/libunwind/include
+     NO_DEFAULT_PATH
++    NO_CMAKE_FIND_ROOT_PATH
+   )
+
+   if (LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL STREQUAL "LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL-NOTFOUND")
--

2.17.1

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot

#2 lore raw

PATCH 1/1 libcxx: new package

Am So., 21. Okt. 2018 um 13:20 Uhr schrieb Romain Naour <[email protected]>:

Quoted 19 lines

Hi Norbert,

Le 13/06/2018 ? 16:14, Norbert Lange a ?crit :

Quoted 8 lines

provides llvm's libc++ as package, probably needs some more work to
better fit into buildroots toolchain construction.

It should be build after the host-g++ and C-Library, but before any other packages and it does install a small script host/bin/<xa-y-z>-g++-libc++
to allow easy use.

You should take into account the external toolchain case.

Quoted 4 lines

For lowlevel language support ABI, it can be built with libstdc++ support library or its own libc++-abi.

Quoted 8 lines
Quoted 4 lines

the parent LLVM software needs to be available, apparently for a few tools. Its downloaded currently, as depending on host-llvm means this package has to be built - which takes forever.

By now, llvm package is merged and updated to llvm 7.0.
Can you try building libcxx as a standalone package (LIBCXX_STANDALONE_BUILD=ON) using the llvm package provided by Buildroot ?

It is a standalone package, but its needing a few scripts from LLVMs buildsystem, I dont otherwise need to build/install anything from LLVM.

so I dont fully get the request. As noted, I could get those scripts from host-llvm but then I need that built (completely), even if libcxx would be independent (or rather sitting below the llvm package).

or do you mean I should add options for building libcxx to the buildroots llvm package?

Quoted 12 lines

Also libcxx and libcxxabi should be packaged separately.

Review

Quoted 8 lines

In the future, a option could potentially compile
all C++ Packages with this library.

(quoted diff) +0 -3
-   depend on threading library if available?
    (supposedly builds without)
-   proper integration in toolchain step
-   use libc++ for remaining packages
Quoted 4 lines

Also you can take a look at the report from the FOSDEM meeting and the final report from Valentin:
https://elinux.org/Buildroot:DeveloperDaysFOSDEM2018#LLVM.2FClang
http://www.linuxembedded.fr/2018/07/llvmclang-integration-into-buildroot

This does not really help, as that document deals with several libraries depending on llvm. The issues I have are with offering a second c++ std library, and as its noted, toolchain support for llvm/clang which aint avaliable in Buildroot for now.

Quoted 34 lines
Quoted 34 lines
---
 package/Config.in                             |   1 +
 package/libcxx/Config.in                      |  29 +++++
 package/libcxx/g++-libc++.in                  |  16 +++
 package/libcxx/libcxx.hash                    |   7 ++
 package/libcxx/libcxx.mk                      | 108 ++++++++++++++++++
 ...i_fix_find_fpath_when_crosscompiling.patch |  27 +++++
 6 files changed, 188 insertions(+)
 create mode 100644 package/libcxx/Config.in
 create mode 100644 package/libcxx/g++-libc++.in
 create mode 100644 package/libcxx/libcxx.hash
 create mode 100644 package/libcxx/libcxx.mk
 create mode 100644 package/libcxx/libcxxabi_fix_find_fpath_when_crosscompiling.patch
package/Config.in +1 -0
index fcabed4fde..cda825612a 100644
@@ -1565,6 +1565,7 @@ menu "Other"
      source "package/lightning/Config.in"
      source "package/linux-pam/Config.in"
      source "package/llvm/Config.in"
+     source "package/libcxx/Config.in"
 if BR2_PACKAGE_LINUX_PAM
 comment "linux-pam plugins"
      source "package/libpam-radius-auth/Config.in"
package/libcxx/Config.in new file +0 -0
new file mode 100644
index 0000000000..f5ff911b6d
Quoted 8 lines

package/libcxx/Config.in line 3

Quoted 4 lines
package/libcxx/Config.in new file +3 -0
@@ -0,0 +1,29 @@
+config BR2_PACKAGE_LIBCXX
+     bool "libc++"
+     depends on BR2_INSTALL_LIBSTDCPP

C++ dependency is not enough for C++11 dependency, you should add a dependency on gcc >= 4.8 (at least).
Also add a dependency on llvm supported architectures.

Ok will look at that.

Quoted 22 lines
Quoted 22 lines
package/libcxx/Config.in new file +21 -0
+     help
+       libc++ is a new implementation of the C++ standard library,
+       targeting C++11 (and newer). Part of the LLVM Project.
+
+       The LLVM Project is a collection of modular and reusable
+       compiler and toolchain technologies.
+
+if BR2_PACKAGE_LIBCXX
+choice
+     prompt "libc++ abi support"
+     default BR2_PACKAGE_LIBCXX_ABI_SUPCXX
+     help
+       Select the c++ abi support: libsupc++ (from gcc toolchain)
+       or libc++-abi (from llvm).
+
+config BR2_PACKAGE_LIBCXX_ABI_SUPCXX
+     bool "libsupc++"
+
+config BR2_PACKAGE_LIBCXX_ABI_CXXABI
+     bool "libc++-abi"
+
Quoted 8 lines

package/libcxx/g++-libc++.in

Quoted 6 lines
package/libcxx/Config.in new file +5 -0
+endchoice
+endif
+
+comment "libc++ needs a toolchain w/ C++"
+     depends on !BR2_INSTALL_LIBSTDCPP
package/libcxx/g++-libc++.in +0 -0

What's the purpose of this script ?

You will end up with 2 C++ standard libraries,
one from the GCC Toolchain (libstdc++) and
one from this package (libc++).

The script will add the necessary flags to GCC to
use correct include paths and linkerflags.

in other words, if eg. use this line, then the package will use libc++:
./configure CXX=g++-libc++ CC=gchost-llvmc

Quoted 42 lines
Quoted 42 lines

new file mode 100644
index 0000000000..db6d050a7c

package/libcxx/g++-libc++.in new file +16 -0
@@ -0,0 +1,16 @@
+#!/bin/sh
+SCRIPTPATH=$(readlink -f "$(dirname "$0")")
+cxx_libs="-lc++ @link_abi@"
+c_libs="-lc @link_comrt@"
+pthread_libs="-lpthread $c_libs"
+
+libs="$cxx_libs $c_libs"
+
+for i; do
+    if test x"$i" = x"-pthread"; then
+        libs="$libs $pthread_libs"
+        break
+    fi
+done
+
+exec "$SCRIPTPATH"/@TARGET_CROSS at g++ -nodefaultlibs -nostdinc++ $libs -isystem"$SCRIPTPATH"/../../staging/usr/include/c++/v1 "$@"
package/libcxx/libcxx.hash new file +7 -0
new file mode 100644
index 0000000000..7d384365b6
@@ -0,0 +1,7 @@
+# locally calculated
+sha256  1ff53c915b4e761ef400b803f07261ade637b0c269d99569f18040f3dcee4408  llvm-6.0.0.src.tar.xz
+sha256  70931a87bde9d358af6cb7869e7535ec6b015f7e6df64def6d2ecdd954040dd9  libcxx-6.0.0.src.tar.xz
+sha256  91c6d9c5426306ce28d0627d6a4448e7d164d6a3f64b01cb1d196003b16d641b  libcxxabi-6.0.0.src.tar.xz
+
+
+sha256  c1938c0e9e90639d1e8f5a7f6bebaab83a3642e0ee44295a4c69934686d0bda8  LICENSE.TXT
package/libcxx/libcxx.mk new file +1 -0
new file mode 100644
index 0000000000..9d9efc90b0
@@ -0,0 +1,108 @@
+################################################################################
Quoted 8 lines

package/libcxx/libcxx.mk line 7

Quoted 6 lines
package/libcxx/libcxx.mk new file +6 -0
+#
+# libc++
+#
+################################################################################
+
+LIBCXX_VERSION = 6.0.0

Can you try with 7.0.0 version ?

Yeah will do when I got some time.

Quoted 11 lines

package/libcxx/libcxx.mk line 15

Quoted 9 lines
package/libcxx/libcxx.mk new file +8 -0
+LIBCXX_SITE = http://llvm.org/releases/$(LIBCXX_VERSION)
+LIBCXX_SOURCE = llvm-$(LIBCXX_VERSION).src.tar.xz
+LIBCXX_LICENSE = MIT
+#LIBCXX_LICENSE_FILES = COPYRIGHT
+LIBCXX_SUPPORTS_IN_SOURCE_BUILD = NO
+LIBCXX_INSTALL_STAGING = YES
+
+LIBCXX_EXTRA_DOWNLOADS = $(patsubst %,$(LIBCXX_SITE)/%-$(LIBCXX_VERSION).src.tar.xz,libcxx libcxxabi)

Can you try to package libcxx and libcxxabi separately ?

I considered that and had some problems with it, the commands that need to be passed to gcc will depend on whether libcxx uses libcxxabi or the gcc equivalent, so those packages are closely related.

LLVM is generally pretty monolithic to build aswell, its easiest to tell its build system what you want so the dependent libraries will be configured correctly.

Quoted 102 lines

package/libcxx/libcxxabi_fix_find_fpath_when_crosscompiling.patch

Quoted 98 lines
package/libcxx/libcxx.mk new file +92 -0
+
+define LIBCXX_EXTRA_EXTRACT
+     $(foreach arch,$(LIBCXX_EXTRA_DOWNLOADS), \
+             TDIR=projects/$(patsubst $(LIBCXX_SITE)/%-$(LIBCXX_VERSION).src.tar.xz,%,$(arch)); \
+             mkdir -p $(@D)/$$TDIR && \
+             $(call suitable-extractor,$(notdir $(arch))) $(LIBCXX_DL_DIR)/$(notdir $(arch)) | \
+             $(TAR) --strip-components=1 -C $(@D)/$$TDIR $(TAR_OPTIONS) -
+     )
+endef> +
+LIBCXX_POST_EXTRACT_HOOKS += LIBCXX_EXTRA_EXTRACT
+
+# Before libcxx is configured, we must have the first stage
+# cross-compiler and the clibrary
+LIBCXX_DEPENDENCIES = host-gcc-initial
+
+ifeq ($(BR2_PACKAGE_LIBCXX_ABI_CXXABI),y)
+_LIBCXX_ABI_TARGET = cxxabi
+endif
+
+_LIBCXX_ABI-$(BR2_PACKAGE_LIBCXX_ABI_CXXABI) = libcxxabi
+_LIBCXX_ABI-$(BR2_PACKAGE_LIBCXX_ABI_SUPCXX) = libsupc++
+
+_LIBCXX_ABI_LINK-$(BR2_PACKAGE_LIBCXX_ABI_CXXABI) = c++abi
+_LIBCXX_ABI_LINK-$(BR2_PACKAGE_LIBCXX_ABI_SUPCXX) = supc++
+
+LIBCXX_MAKE_OPTS = $(_LIBCXX_ABI_TARGET) cxx
+
+LIBCXX_INSTALL_STAGING_OPTS = DESTDIR=$(STAGING_DIR) $(addprefix install-,$(_LIBCXX_ABI_TARGET) cxx)
+
+LIBCXX_INSTALL_TARGET_OPTS = DESTDIR=$(TARGET_DIR) $(addprefix install-,$(_LIBCXX_ABI_TARGET) cxx)
+
+
+#LIBCXXABI_SYSROOT LIBCXX_SYSROOT
+# TODO: potentially depend on threading library?
+# allow using gccs libsupc++
+# consider whether its better to statically link libc++-abi
+# USe this library to build the remaining C++ packages?
+
+# llvm does not recommend using this
+LIBCXX_CONF_OPTS += -DBUILD_SHARED_LIBS:BOOL=OFF
+
+LIBCXX_CONF_OPTS += -DLIBCXXABI_INCLUDE_TESTS=OFF -DLIBCXXABI_ENABLE_ASSERTIONS=OFF -DLIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS=OFF -DLIBCXX_ENABLE_NEW_DELETE_DEFINITIONS=ON
+
+ifeq ($(BR2_TOOLCHAIN_USES_MUSL),y)
+LIBCXX_CONF_OPTS += -DLIBCXX_HAS_MUSL_LIBC:BOOL=ON
+endif
+
+ifeq ($(BR2_SHARED_LIBS)$(BR2_SHARED_STATIC_LIBS),y)
+LIBCXX_CONF_OPTS += -DLIBCXXABI_ENABLE_SHARED:BOOL=ON -DLIBCXX_ENABLE_SHARED:BOOL=ON
+else
+LIBCXX_CONF_OPTS += -DLIBCXXABI_ENABLE_SHARED:BOOL=OFF -DLIBCXX_ENABLE_SHARED:BOOL=OFF
+endif
+
+ifeq ($(BR2_STATIC_LIBS)$(BR2_SHARED_STATIC_LIBS),y)
+LIBCXX_CONF_OPTS += -DLIBCXXABI_ENABLE_STATIC:BOOL=ON -DLIBCXX_ENABLE_STATIC:BOOL=ON
+else
+LIBCXX_CONF_OPTS += -DLIBCXXABI_ENABLE_STATIC:BOOL=OFF -DLIBCXX_ENABLE_STATIC:BOOL=OFF
+endif
+
+LIBCXX_CONF_OPTS += -DLIBCXX_ENABLE_ABI_LINKER_SCRIPT=ON
+
+#LIBCXX_CONF_OPTS += -DLLVM_PATH:PATH=$(@D)/llvm
+
+#LIBCXX_CONF_OPTS += -DLIBCXX_CXX_ABI:STRING=default
+
+# libc++ needs to be massaged to pick header and libs
+LIBCXX_CONF_OPTS += -DLIBCXX_CXX_ABI:STRING=$(_LIBCXX_ABI-y)
+
+ifneq ($(_LIBCXX_ABI_TARGET),)
+LIBCXX_CONF_OPTS += -DLIBCXX_CXX_ABI_INCLUDE_PATHS:PATH=$(@D)/projects/libcxxabi/include \
+                                     -DLIBCXX_CXX_ABI_LIBRARY_PATH:PATH=../../../lib
+endif
+
+
+#LIBCXX_CONF_OPTS += -DLIBCXX_INCLUDE_BENCHMARKS:BOOL=OFF
+#LIBCXX_CONF_OPTS += -DLIBCXX_INCLUDE_DOCS:BOOL=OFF
+#LIBCXX_CONF_OPTS += -DLIBCXX_INCLUDE_TESTS:BOOL=OFF
+
+cxx_libs="-lc++ @link_abi@"
+c_libs="-lc @link_comrt@"
+
+# Create a g++ wrapper to add the necessary aguments for building with libc++
+define LIBCXX_CREATE_GXXWRAPPER_TARGET
+     sed -e 's, at TARGET_CROSS@,$(notdir $(TARGET_CROSS)),g' \
+       -e 's, at link_abi@,$(addprefix -l,$(_LIBCXX_ABI_LINK-y)),g' \
+       -e 's, at link_comrt@,-lgcc_s,g' \
+       $(LIBCXX_PKGDIR)g++-libc++.in > $(LIBCXX_BUILDDIR)gxxwrap.tmp
+     install -D -m755 $(LIBCXX_BUILDDIR)gxxwrap.tmp $(TARGET_CROSS)g++-libc++
+endef
+LIBCXX_POST_INSTALL_TARGET_HOOKS = LIBCXX_CREATE_GXXWRAPPER_TARGET
+
+$(eval $(cmake-package))
package/libcxx/libcxxabi_fix_find_fpath_when_crosscompiling.patch new file +0 -0
new file mode 100644
index 0000000000..2fd95178f7

Please, provide a patch generated with git format-patch with a commit log, upstream status and you SoB line.

Quoted 2 lines

I'll mark you patch "Change Requested" in the patchwork, please send an updated version.

Will do (hopefully I don't need patches with 7.0.0, this one was nipped from upstream and should have ended in 7.0.0).

Norbert