From 8e3b8e080571ee2c8a2bf6c31a4f10b093547d93 Mon Sep 17 00:00:00 2001 From: GasInfinity Date: Wed, 20 Nov 2024 11:28:13 +0100 Subject: [PATCH] pkgs/build-support: cc-wrapper.sh not detecting c++ files by extension some build systems expect the compiler to detect the language by file extension, this fixes that case by checking if any supported c++ file has been passed to the compiler and update the flags accordingly. Extensions taken from clang 4d6a5fc702e568b0456c4d8f9e2307eb6d81e955. --- pkgs/build-support/cc-wrapper/cc-wrapper.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkgs/build-support/cc-wrapper/cc-wrapper.sh b/pkgs/build-support/cc-wrapper/cc-wrapper.sh index da1a709684dac..3d2e3544f1a9f 100644 --- a/pkgs/build-support/cc-wrapper/cc-wrapper.sh +++ b/pkgs/build-support/cc-wrapper/cc-wrapper.sh @@ -56,6 +56,9 @@ while (( "$n" < "$nParams" )); do c++*) isCxx=1 ;; esac ;; + # check common c++ file extensions + # taken from clang: https://github.com/llvm/llvm-project/blob/4d6a5fc702e568b0456c4d8f9e2307eb6d81e955/clang/lib/Driver/Types.cpp#L299-L369 + *.C|*.H|*.cc|*.CC|*.cp|*.hh|*.ccm|*.cpp|*.CPP|*.c++|*.C++|*.cxx|*.CXX|*.hpp|*.hxx|*.c++m|*.cppm|*.cxxm) isCxx=1 ;; --) # Everything else is positional args! # See: https://github.com/llvm/llvm-project/commit/ed1d07282cc9d8e4c25d585e03e5c8a1b6f63a74 @@ -65,6 +68,12 @@ while (( "$n" < "$nParams" )); do positionalArgs=("${params[@]:$n}") params=("${params[@]:0:$((n - 1))}") + + for pa in "${positionalArgs[@]}"; do + case $pa in + *.C|*.H|*.cc|*.CC|*.cp|*.hh|*.ccm|*.cpp|*.CPP|*.c++|*.C++|*.cxx|*.CXX|*.hpp|*.hxx|*.c++m|*.cppm|*.cxxm) isCxx=1 ;; + esac + done break; ;; -?*) ;;