Sun, 12 Jan 2025 16:28:08 +0100
improve toolchain detection to also get the wordsize and stdc version, issue #439, issue #508
--- a/src/main/resources/make/configure.vm Sun Jan 12 13:23:35 2025 +0100 +++ b/src/main/resources/make/configure.vm Sun Jan 12 16:28:08 2025 +0100 @@ -488,11 +488,11 @@ # build type if [ "$BUILD_TYPE" = "debug" ]; then TEMP_CFLAGS="\${DEBUG_CFLAGS}$TEMP_CFLAGS" - TEMP_CXXFLAGS="\${DEBUG_CXXFLAGS}$TEMP_CXXFLAGS" + TEMP_CXXFLAGS="\${DEBUG_CXXFLAGS}$TEMP_CXXFLAGS" fi if [ "$BUILD_TYPE" = "release" ]; then - TEMP_CFLAGS="\${RELEASE_CFLAGS}$TEMP_CFLAGS" - TEMP_CXXFLAGS="\${RELEASE_CXXFLAGS}$TEMP_CXXFLAGS" + TEMP_CFLAGS="\${RELEASE_CFLAGS}$TEMP_CFLAGS" + TEMP_CXXFLAGS="\${RELEASE_CXXFLAGS}$TEMP_CXXFLAGS" fi # add general dependency flags to flags.mk
--- a/src/main/resources/make/toolchain.sh Sun Jan 12 13:23:35 2025 +0100 +++ b/src/main/resources/make/toolchain.sh Sun Jan 12 16:28:08 2025 +0100 @@ -26,15 +26,19 @@ #include <stdio.h> int main(int argc, char **argv) { #if defined(_MSC_VER) - printf("msc\n"); + printf("toolchain:msc\n"); #elif defined(__clang__) - printf("clang gnuc\n"); + printf("toolchain:clang gnuc\n"); #elif defined(__GNUC__) - printf("gcc gnuc\n"); + printf("toolchain:gcc gnuc\n"); #elif defined(__sun) - printf("suncc\n"); + printf("toolchain:suncc\n"); #else - printf("unknown\n"); + printf("toolchain:unknown\n"); +#endif + printf("wsize:%d\n", (int)sizeof(void*)*8); +#ifdef __STDC_VERSION__ + printf("stdcversion:%d\n", __STDC_VERSION__); #endif return 0; } @@ -54,16 +58,17 @@ #include <iostream> int main(int argc, char **argv) { #if defined(_MSC_VER) - std::cout << "msc" << std::endl; + std::cout << "toolchain:msc" << std::endl; #elif defined(__clang__) - std::cout << "clang gnuc" << std::endl; + std::cout << "toolchain:clang gnuc" << std::endl; #elif defined(__GNUC__) - std::cout << "gcc gnuc" << std::endl; + std::cout << "toolchain:gcc gnuc" << std::endl; #elif defined(__sun) - std::cout << "suncc" << std::endl; + std::cout << "toolchain:suncc" << std::endl; #else - std::cout << "cc" << std::endl; + std::cout << "toolchain:unknown" << std::endl; #endif + std:cout << "wsize:" << sizeof(void*)*8 << std::endl; return 0; } __EOF__ @@ -130,8 +135,11 @@ if [ -n "$CC" ]; then if check_c_compiler "$CC"; then TOOLCHAIN_CC=$CC - TOOLCHAIN=`"$TEMP_DIR/checkcc"` + "$TEMP_DIR/checkcc" > "$TEMP_DIR/checkcc_out" + TOOLCHAIN=`grep '^toolchain:' "$TEMP_DIR/checkcc_out" | tail -c +11` TOOLCHAIN_NAME=`echo "$TOOLCHAIN" | cut -f1 -d' ' -` + TOOLCHAIN_WSIZE=`grep '^wsize:' "$TEMP_DIR/checkcc_out" | tail -c +7` + TOOLCHAIN_CSTD=`grep '^stdcversion:' "$TEMP_DIR/checkcc_out" | tail -c +13` echo "$CC" return 0 else @@ -143,8 +151,11 @@ do if check_c_compiler "$COMP"; then TOOLCHAIN_CC=$COMP - TOOLCHAIN=`"$TEMP_DIR/checkcc"` + "$TEMP_DIR/checkcc" > "$TEMP_DIR/checkcc_out" + TOOLCHAIN=`grep '^toolchain:' "$TEMP_DIR/checkcc_out" | tail -c +11` TOOLCHAIN_NAME=`echo "$TOOLCHAIN" | cut -f1 -d' ' -` + TOOLCHAIN_WSIZE=`grep '^wsize:' "$TEMP_DIR/checkcc_out" | tail -c +7` + TOOLCHAIN_CSTD=`grep '^stdcversion:' "$TEMP_DIR/checkcc_out" | tail -c +13` echo "$COMP" return 0 fi @@ -164,7 +175,8 @@ if [ -n "$CXX" ]; then if check_cpp_compiler "$CXX"; then TOOLCHAIN_CXX=$CXX - TOOLCHAIN=`"$TEMP_DIR/checkcc"` + "$TEMP_DIR/checkcc" > "$TEMP_DIR/checkcc_out" + TOOLCHAIN=`grep '^toolchain:' "$TEMP_DIR/checkcc_out" | tail -c +11` TOOLCHAIN_NAME=`echo "$TOOLCHAIN" | cut -f1 -d' ' -` echo "$CXX" return 0 @@ -177,7 +189,8 @@ do if check_cpp_compiler "$COMP"; then TOOLCHAIN_CXX=$COMP - TOOLCHAIN=`"$TEMP_DIR/checkcc"` + "$TEMP_DIR/checkcc" > "$TEMP_DIR/checkcc_out" + TOOLCHAIN=`grep '^toolchain:' "$TEMP_DIR/checkcc_out" | tail -c +11` TOOLCHAIN_NAME=`echo "$TOOLCHAIN" | cut -f1 -d' ' -` echo "$COMP" return 0
--- a/test/make/toolchain.sh Sun Jan 12 13:23:35 2025 +0100 +++ b/test/make/toolchain.sh Sun Jan 12 16:28:08 2025 +0100 @@ -26,15 +26,19 @@ #include <stdio.h> int main(int argc, char **argv) { #if defined(_MSC_VER) - printf("msc\n"); + printf("toolchain:msc\n"); #elif defined(__clang__) - printf("clang gnuc\n"); + printf("toolchain:clang gnuc\n"); #elif defined(__GNUC__) - printf("gcc gnuc\n"); + printf("toolchain:gcc gnuc\n"); #elif defined(__sun) - printf("suncc\n"); + printf("toolchain:suncc\n"); #else - printf("unknown\n"); + printf("toolchain:unknown\n"); +#endif + printf("wsize:%d\n", (int)sizeof(void*)*8); +#ifdef __STDC_VERSION__ + printf("stdcversion:%d\n", __STDC_VERSION__); #endif return 0; } @@ -54,16 +58,17 @@ #include <iostream> int main(int argc, char **argv) { #if defined(_MSC_VER) - std::cout << "msc" << std::endl; + std::cout << "toolchain:msc" << std::endl; #elif defined(__clang__) - std::cout << "clang gnuc" << std::endl; + std::cout << "toolchain:clang gnuc" << std::endl; #elif defined(__GNUC__) - std::cout << "gcc gnuc" << std::endl; + std::cout << "toolchain:gcc gnuc" << std::endl; #elif defined(__sun) - std::cout << "suncc" << std::endl; + std::cout << "toolchain:suncc" << std::endl; #else - std::cout << "cc" << std::endl; + std::cout << "toolchain:unknown" << std::endl; #endif + std:cout << "wsize:" << sizeof(void*)*8 << std::endl; return 0; } __EOF__ @@ -130,8 +135,11 @@ if [ -n "$CC" ]; then if check_c_compiler "$CC"; then TOOLCHAIN_CC=$CC - TOOLCHAIN=`"$TEMP_DIR/checkcc"` + "$TEMP_DIR/checkcc" > "$TEMP_DIR/checkcc_out" + TOOLCHAIN=`grep '^toolchain:' "$TEMP_DIR/checkcc_out" | tail -c +11` TOOLCHAIN_NAME=`echo "$TOOLCHAIN" | cut -f1 -d' ' -` + TOOLCHAIN_WSIZE=`grep '^wsize:' "$TEMP_DIR/checkcc_out" | tail -c +7` + TOOLCHAIN_CSTD=`grep '^stdcversion:' "$TEMP_DIR/checkcc_out" | tail -c +13` echo "$CC" return 0 else @@ -143,8 +151,11 @@ do if check_c_compiler "$COMP"; then TOOLCHAIN_CC=$COMP - TOOLCHAIN=`"$TEMP_DIR/checkcc"` + "$TEMP_DIR/checkcc" > "$TEMP_DIR/checkcc_out" + TOOLCHAIN=`grep '^toolchain:' "$TEMP_DIR/checkcc_out" | tail -c +11` TOOLCHAIN_NAME=`echo "$TOOLCHAIN" | cut -f1 -d' ' -` + TOOLCHAIN_WSIZE=`grep '^wsize:' "$TEMP_DIR/checkcc_out" | tail -c +7` + TOOLCHAIN_CSTD=`grep '^stdcversion:' "$TEMP_DIR/checkcc_out" | tail -c +13` echo "$COMP" return 0 fi @@ -164,7 +175,8 @@ if [ -n "$CXX" ]; then if check_cpp_compiler "$CXX"; then TOOLCHAIN_CXX=$CXX - TOOLCHAIN=`"$TEMP_DIR/checkcc"` + "$TEMP_DIR/checkcc" > "$TEMP_DIR/checkcc_out" + TOOLCHAIN=`grep '^toolchain:' "$TEMP_DIR/checkcc_out" | tail -c +11` TOOLCHAIN_NAME=`echo "$TOOLCHAIN" | cut -f1 -d' ' -` echo "$CXX" return 0 @@ -177,7 +189,8 @@ do if check_cpp_compiler "$COMP"; then TOOLCHAIN_CXX=$COMP - TOOLCHAIN=`"$TEMP_DIR/checkcc"` + "$TEMP_DIR/checkcc" > "$TEMP_DIR/checkcc_out" + TOOLCHAIN=`grep '^toolchain:' "$TEMP_DIR/checkcc_out" | tail -c +11` TOOLCHAIN_NAME=`echo "$TOOLCHAIN" | cut -f1 -d' ' -` echo "$COMP" return 0