[Git][ghc/ghc][wip/freebsd-ci] system-cxx-std-lib: Add support for FreeBSD libcxxrt
Ben Gamari (@bgamari)
gitlab at gitlab.haskell.org
Sun Aug 7 23:46:32 UTC 2022
Ben Gamari pushed to branch wip/freebsd-ci at Glasgow Haskell Compiler / GHC
Commits:
48d748a2 by Ben Gamari at 2022-08-07T19:46:27-04:00
system-cxx-std-lib: Add support for FreeBSD libcxxrt
- - - - -
1 changed file:
- m4/fp_find_cxx_std_lib.m4
Changes:
=====================================
m4/fp_find_cxx_std_lib.m4
=====================================
@@ -18,10 +18,44 @@ unknown
#endif
EOF
AC_MSG_CHECKING([C++ standard library flavour])
- if "$CXX" -E actest.cpp -o actest.out; then
- if grep "libc++" actest.out >/dev/null; then
- CXX_STD_LIB_LIBS="c++ c++abi"
- p="`"$CXX" --print-file-name libc++.so`"
+ if ! "$CXX" -E actest.cpp -o actest.out; then
+ rm -f actest.cpp actest.out
+ AC_MSG_ERROR([Failed to compile test program])
+ fi
+
+ dnl Identify standard library type
+ if grep "libc++" actest.out >/dev/null; then
+ CXX_STD_LIB_FLAVOUR="c++"
+ AC_MSG_RESULT([libc++])
+ elif grep "libstdc++" actest.out >/dev/null; then
+ CXX_STD_LIB_FLAVOUR="stdc++"
+ AC_MSG_RESULT([libstdc++])
+ else
+ rm -f actest.cpp actest.out
+ AC_MSG_ERROR([Unknown C++ standard library implementation.])
+ fi
+ rm -f actest.cpp actest.out
+
+ dnl -----------------------------------------
+ dnl Figure out how to link...
+ dnl -----------------------------------------
+ cat >actest.cpp <<-EOF
+#include <iostream>
+int main(int argc, char** argv) {
+ std::cout << "hello world\n";
+ return 0;
+}
+EOF
+ if ! "$CXX" -c actest.cpp; then
+ AC_MSG_ERROR([Failed to compile test object])
+ fi
+
+ try_libs() {
+ dnl Try to link a plain object with CC manually
+ AC_MSG_CHECKING([for linkage against '${3}'])
+ if "$CC" -o actest actest.o ${1} 2>/dev/null; then
+ CXX_STD_LIB_LIBS="${3}"
+ p="`"$CXX" --print-file-name ${2}`"
d="`dirname "$p"`"
dnl On some platforms (e.g. Windows) the C++ standard library
dnl can be found in the system search path. In this case $CXX
@@ -31,24 +65,25 @@ EOF
if test "$d" = "."; then d=""; fi
CXX_STD_LIB_LIB_DIRS="$d"
CXX_STD_LIB_DYN_LIB_DIRS="$d"
- AC_MSG_RESULT([libc++])
- elif grep "libstdc++" actest.out >/dev/null; then
- CXX_STD_LIB_LIBS="stdc++"
- p="`"$CXX" --print-file-name libstdc++.so`"
- d="`dirname "$p"`"
- if test "$d" = "."; then d=""; fi
- CXX_STD_LIB_LIB_DIRS="$d"
- CXX_STD_LIB_DYN_LIB_DIRS="$d"
- AC_MSG_RESULT([libstdc++])
+ AC_MSG_RESULT([success])
+ true
else
- rm -f actest.cpp actest.out
- AC_MSG_ERROR([Unknown C++ standard library implementation.])
+ AC_MSG_RESULT([failed])
+ false
fi
- rm -f actest.cpp actest.out
- else
- rm -f actest.cpp actest.out
- AC_MSG_ERROR([Failed to compile test program])
- fi
+ }
+ case $CXX_STD_LIB_FLAVOUR in
+ c++)
+ try_libs "-lc++ -lc++abi" "libc++.so" "c++ c++abi" || \
+ try_libs "-lc++ -lcxxrt" "libc++.so" "c++ cxxrt" ||
+ AC_MSG_ERROR([Failed to find C++ standard library]) ;;
+ stdc++)
+ try_libs "-lstdc++" "libstdc++.so" "stdc++" || \
+ try_libs "-lstdc++ -lsupc++" "libstdc++.so" "stdc++ supc++" || \
+ AC_MSG_ERROR([Failed to find C++ standard library]) ;;
+ esac
+
+ rm -f actest.cpp actest.o actest
fi
AC_SUBST([CXX_STD_LIB_LIBS])
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/48d748a26f71be43d6bd60db01a99b2435490cfd
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/48d748a26f71be43d6bd60db01a99b2435490cfd
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20220807/fdc6a1da/attachment-0001.html>
More information about the ghc-commits
mailing list