Failed to compile the last version 2022.0.0 with MinGW under Windows 10 : Error in CMake "math cannot parse the expression"
Summary
Hi,
I was not able to compile the oneTBB library for the last version 2022.0.0 (it works fine with the previous version 2021.13.0)
Version
Version 2022.0.0
Environment
Windows 10 CMake 3.30.2 mingw64-13.2.0 for GCC and G++ compiler
gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=C:/mingw64-13.2.0/bin/../libexec/gcc/x86_64-w64-mingw32/13.2.0/lto-wrapper.exe Target: x86_64-w64-mingw32 Configured with: ../../../src/gcc-13.2.0/configure --host=x86_64-w64-mingw32 --build=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --prefix=/mingw64 --with-sysroot=/c/buildroot/x86_64-1320-win32-seh-ucrt-rt_v11-rev1/mingw64 --enable-host-shared --disable-multilib --enable-languages=c,c++,fortran,lto --enable-libstdcxx-time=yes --enable-threads=win32 --enable-libstdcxx-threads=yes --enable-libgomp --enable-libatomic --enable-lto --enable-graphite --enable-checking=release --enable-fully-dynamic-string --enable-version-specific-runtime-libs --enable-libstdcxx-filesystem-ts=yes --disable-libssp --disable-libstdcxx-pch --disable-libstdcxx-debug --enable-bootstrap --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-gnu-as --with-gnu-ld --with-arch=nocona --with-tune=core2 --with-libiconv --with-system-zlib --with-gmp=/c/buildroot/prerequisites/x86_64-w64-mingw32-static --with-mpfr=/c/buildroot/prerequisites/x86_64-w64-mingw32-static --with-mpc=/c/buildroot/prerequisites/x86_64-w64-mingw32-static --with-isl=/c/buildroot/prerequisites/x86_64-w64-mingw32-static --with-pkgversion='x86_64-win32-seh-rev1, Built by MinGW-Builds project' --with-bugurl=https://github.com/niXman/mingw-builds CFLAGS='-O2 -pipe -fno-ident -I/c/buildroot/x86_64-1320-win32-seh-ucrt-rt_v11-rev1/mingw64/opt/include -I/c/buildroot/prerequisites/x86_64-zlib-static/include -I/c/buildroot/prerequisites/x86_64-w64-mingw32-static/include' CXXFLAGS='-O2 -pipe -fno-ident -I/c/buildroot/x86_64-1320-win32-seh-ucrt-rt_v11-rev1/mingw64/opt/include -I/c/buildroot/prerequisites/x86_64-zlib-static/include -I/c/buildroot/prerequisites/x86_64-w64-mingw32-static/include' CPPFLAGS=' -I/c/buildroot/x86_64-1320-win32-seh-ucrt-rt_v11-rev1/mingw64/opt/include -I/c/buildroot/prerequisites/x86_64-zlib-static/include -I/c/buildroot/prerequisites/x86_64-w64-mingw32-static/include' LDFLAGS='-pipe -fno-ident -L/c/buildroot/x86_64-1320-win32-seh-ucrt-rt_v11-rev1/mingw64/opt/lib -L/c/buildroot/prerequisites/x86_64-zlib-static/lib -L/c/buildroot/prerequisites/x86_64-w64-mingw32-static/lib ' LD_FOR_TARGET=/c/buildroot/x86_64-1320-win32-seh-ucrt-rt_v11-rev1/mingw64/bin/ld.exe --with-boot-ldflags=' -Wl,--disable-dynamicbase -static-libstdc++ -static-libgcc' Thread model: win32 Supported LTO compression algorithms: zlib gcc version 13.2.0 (x86_64-win32-seh-rev1, Built by MinGW-Builds project)
Observed Behavior
The CXX compiler identification is GNU 13.2.0 Detecting CXX compiler ABI info Detecting CXX compiler ABI info - done Check for working CXX compiler: C:/mingw64-13.2.0/bin/c++.exe - skipped Detecting CXX compile features Detecting CXX compile features - done CMAKE_BUILD_TYPE is not specified. Using default: RelWithDebInfo Performing Test CMAKE_HAVE_LIBC_PTHREAD Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed Check if compiler accepts -pthread Check if compiler accepts -pthread - yes Found Threads: TRUE IPO enabled CMake Error at cmake/compilers/GNU.cmake:65 (math): math cannot parse the expression: "g++.exe: fatal error: input file '/dev/null' is the same as output file
compilation terminated. * 1000 + g++.exe: fatal error: input file '/dev/null' is the same as output file
compilation terminated.": syntax error, unexpected exp_DIVIDE (35). Call Stack (most recent call first): CMakeLists.txt:234 (include)
GNU Assembler version: c++.exe: fatal error: input file '/dev/null' is the same as output file compilation terminated..c++.exe: fatal error: input file '/dev/null' is the same as output file compilation terminated. (ERROR) The C compiler identification is GNU 13.2.0 Detecting C compiler ABI info Detecting C compiler ABI info - done Check for working C compiler: C:/mingw64-13.2.0/bin/gcc.exe - skipped Detecting C compile features Detecting C compile features - done HWLOC target HWLOC::hwloc_1_11 doesn't exist. The tbbbind target cannot be created HWLOC target HWLOC::hwloc_2 doesn't exist. The tbbbind_2_0 target cannot be created HWLOC target HWLOC::hwloc_2_5 doesn't exist. The tbbbind_2_5 target cannot be created Performing Test LINKER_HAS_NO_AS_NEEDED Performing Test LINKER_HAS_NO_AS_NEEDED - Success Configuring incomplete, errors occurred!
Expected Behavior
No errors in CMake
Steps To Reproduce
Just load the source file in CMake, press Configure and select "MinGW makefiles" and "Use default native compilers" (assuming you have in your PATH environment the right compiler otherwise select "Specify native compilers" and choose the path to GCC and G++)
Thanks,
Error similar to #1556. I guess the GAS version has a prefix or a suffix on MinGW.
@Jhuighuy Thanks for you reply :) Is there any quick workaround for that ? Thanks
@fdiedler Looks like I've made a misleading comment.
The issue is not related to the GAS version (no easy workaround here by the way, submitted a PR). It looks like there is no /dev/null on MinGW (or it does not behave like on Posix), but I am not very familar with MinGW generally and do not have a Windows machine to test, unfortunately.
For a quick workaround, I think, here you can replace
execute_process(
COMMAND ${CMAKE_COMMAND} -E env "LANG=C" ${CMAKE_CXX_COMPILER} -xc -c /dev/null -Wa,-v -o/dev/null
OUTPUT_VARIABLE ASSEMBLER_VERSION_LINE_OUT
ERROR_VARIABLE ASSEMBLER_VERSION_LINE_ERR
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_STRIP_TRAILING_WHITESPACE
)
with something like
set(_empty_file "${CMAKE_BINARY_DIR}/empty.c")
file(TOUCH "${_empty_file}")
execute_process(
COMMAND ${CMAKE_CXX_COMPILER} -Wa,-v -c "${_empty_file}" -o "${_empty_file}.o"
OUTPUT_VARIABLE ASSEMBLER_VERSION_LINE_OUT
ERROR_VARIABLE ASSEMBLER_VERSION_LINE_ERR
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_STRIP_TRAILING_WHITESPACE
)
file(REMOVE "${_empty_file}")
file(REMOVE "${_empty_file}.o")
unset(_empty_file)
If it helps, a PR can be submitted.
@Jhuighuy Thanks, seems to works just have a message :
[ 11%] Linking CXX shared library ....\gnu_13.2_cxx11_64_relwithdebinfo\libtbb12.dll C:\mingw64-13.2.0\bin\ar.exe: CMakeFiles/tbb.dir/address_waiter.cpp.obj: plugin needed to handle lto object
What does it means ?
I also have an error while building tests :
[ 17%] Built target test_dynamic_link [ 17%] Building CXX object test/CMakeFiles/test_numa_dist.dir/tbb/test_numa_dist.cpp.obj C:\oneTBB-2022.0.0\test\tbb\test_numa_dist.cpp: In lambda function: C:\oneTBB-2022.0.0\test\tbb\test_numa_dist.cpp:93:34: error: declaration of 'proc' shadows a previous local [-Werror=shadow] 93 | PROCESSOR_NUMBER proc; | ^~~~ compilation terminated due to -Wfatal-errors. cc1plus.exe: all warnings being treated as errors make[2]: *** [test/CMakeFiles/test_numa_dist.dir/tbb/test_numa_dist.cpp.obj] Error 1 make[1]: *** [test/CMakeFiles/test_numa_dist.dir/all] Error 2 make: *** [all] Error 2
Thanks