Skip to content

Failed to build on MinGW-w64 clang 10 #2232

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wumo opened this issue May 20, 2020 · 7 comments
Closed

Failed to build on MinGW-w64 clang 10 #2232

wumo opened this issue May 20, 2020 · 7 comments

Comments

@wumo
Copy link

wumo commented May 20, 2020

Description

When compile glslang on mingw-w64 clang 10, it throws error:

error: no member named 'snprintf' in the global namespace
  using ::snprintf;

OS: Windows 10 1909
cmake: 3.17
msys2: 20200517
clang: 10.0.0

Steps to reproduce

# msys2 installation
pacman -S mingw-w64-x86_64-toolchain mingw-w64-x86_64-clang

# cmake build
mkdir build
cd build
cmake -G "CodeBlocks - MinGW Makefiles" ..
cmake --build .  --target glslangValidator

Error log

-- The C compiler identification is Clang 10.0.0
-- The CXX compiler identification is Clang 10.0.0
-- Check for working C compiler: C:/msys64/mingw64/bin/clang.exe
-- Check for working C compiler: C:/msys64/mingw64/bin/clang.exe - works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/msys64/mingw64/bin/clang++.exe
-- Check for working CXX compiler: C:/msys64/mingw64/bin/clang++.exe - works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PythonInterp: C:/msys64/mingw64/bin/python3.exe (found suitable version "3.8.3", minimum required is "3")
-- Google Mock was not found - tests based on that will not build
-- spirv-tools not linked - illegal SPIRV may be generated for HLSL
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/WDAGUtilityAccount/Desktop/glslang/build

Scanning dependencies of target HLSL
[  1%] Building CXX object hlsl/CMakeFiles/HLSL.dir/hlslAttributes.cpp.obj
[  3%] Building CXX object hlsl/CMakeFiles/HLSL.dir/hlslParseHelper.cpp.obj
[  5%] Building CXX object hlsl/CMakeFiles/HLSL.dir/hlslScanContext.cpp.obj
In file included from C:\Users\WDAGUtilityAccount\Desktop\glslang\hlsl\hlslScanContext.cpp:45:
In file included from C:\Users\WDAGUtilityAccount\Desktop\glslang\hlsl/../glslang/Include/Types.h:43:
In file included from C:\Users\WDAGUtilityAccount\Desktop\glslang\hlsl/../glslang/Include/../Include/Common.h:103:
In file included from C:\msys64\mingw64\include\c++\10.1.0\string:55:
In file included from C:\msys64\mingw64\include\c++\10.1.0\bits/basic_string.h:6535:
In file included from C:\msys64\mingw64\include\c++\10.1.0\ext/string_conversions.h:43:
C:\msys64\mingw64\include\c++\10.1.0\cstdio:175:11: error: no member named 'snprintf' in the global namespace
  using ::snprintf;
        ~~^
C:\msys64\mingw64\include\c++\10.1.0\cstdio:185:22: error: no member named 'snprintf' in namespace '__gnu_cxx'; did you
      mean 'vsnprintf'?
  using ::__gnu_cxx::snprintf;
        ~~~~~~~~~~~~~^
C:\msys64\mingw64\include\c++\10.1.0\cstdio:178:11: note: 'vsnprintf' declared here
  using ::vsnprintf;
          ^
In file included from C:\Users\WDAGUtilityAccount\Desktop\glslang\hlsl\hlslScanContext.cpp:46:
In file included from C:\Users\WDAGUtilityAccount\Desktop\glslang\hlsl/../glslang/MachineIndependent/SymbolTable.h:70:
C:\Users\WDAGUtilityAccount\Desktop\glslang\hlsl/../glslang/Include/../Public/../MachineIndependent/../Include/InfoSink.h:78:58: error:
      use of undeclared identifier 'snprintf'; did you mean 'vsnprintf'?
                                                         snprintf(buf, size, (fabs(n) > 1e-8 && fabs(n) < 1e8) |...
                                                         ^~~~~~~~
                                                         vsnprintf
C:\msys64\mingw64\x86_64-w64-mingw32\include\stdio.h:444:5: note: 'vsnprintf' declared here
int vsnprintf (char *__stream, size_t __n, const char *__format, __builtin_va_list __local_argv)
    ^
In file included from C:\Users\WDAGUtilityAccount\Desktop\glslang\hlsl\hlslScanContext.cpp:46:
In file included from C:\Users\WDAGUtilityAccount\Desktop\glslang\hlsl/../glslang/MachineIndependent/SymbolTable.h:70:
C:\Users\WDAGUtilityAccount\Desktop\glslang\hlsl/../glslang/Include/../Public/../MachineIndependent/../Include/InfoSink.h:78:140: error:
      cannot initialize a parameter of type '__builtin_va_list' with an lvalue of type 'float'
  ...snprintf(buf, size, (fabs(n) > 1e-8 && fabs(n) < 1e8) || n == 0.0f ? "%f" : "%g", n);
                                                                                       ^
C:\msys64\mingw64\x86_64-w64-mingw32\include\stdio.h:444:84: note: passing argument to parameter '__local_argv' here
int vsnprintf (char *__stream, size_t __n, const char *__format, __builtin_va_list __local_argv)
                                                                                   ^
In file included from C:\Users\WDAGUtilityAccount\Desktop\glslang\hlsl\hlslScanContext.cpp:46:
In file included from C:\Users\WDAGUtilityAccount\Desktop\glslang\hlsl/../glslang/MachineIndependent/SymbolTable.h:70:
C:\Users\WDAGUtilityAccount\Desktop\glslang\hlsl/../glslang/Include/../Public/../MachineIndependent/../Include/InfoSink.h:100:9: error:
      use of undeclared identifier 'snprintf'; did you mean 'vsnprintf'?
        snprintf(locText, maxSize, ":%d", loc.line);
        ^~~~~~~~
        vsnprintf
C:\msys64\mingw64\x86_64-w64-mingw32\include\stdio.h:444:5: note: 'vsnprintf' declared here
int vsnprintf (char *__stream, size_t __n, const char *__format, __builtin_va_list __local_argv)
    ^
In file included from C:\Users\WDAGUtilityAccount\Desktop\glslang\hlsl\hlslScanContext.cpp:46:
In file included from C:\Users\WDAGUtilityAccount\Desktop\glslang\hlsl/../glslang/MachineIndependent/SymbolTable.h:70:
C:\Users\WDAGUtilityAccount\Desktop\glslang\hlsl/../glslang/Include/../Public/../MachineIndependent/../Include/InfoSink.h:100:43: error:
      cannot initialize a parameter of type '__builtin_va_list' with an lvalue of type 'const int'
        snprintf(locText, maxSize, ":%d", loc.line);
                                          ^~~~~~~~
C:\msys64\mingw64\x86_64-w64-mingw32\include\stdio.h:444:84: note: passing argument to parameter '__local_argv' here
int vsnprintf (char *__stream, size_t __n, const char *__format, __builtin_va_list __local_argv)
                                                                                   ^
In file included from C:\Users\WDAGUtilityAccount\Desktop\glslang\hlsl\hlslScanContext.cpp:46:
C:\Users\WDAGUtilityAccount\Desktop\glslang\hlsl/../glslang/MachineIndependent/SymbolTable.h:414:13: error: use of
      undeclared identifier 'snprintf'
            snprintf(buf, 20, "%s%d", AnonymousPrefix, symbol.getAsVariable()->getAnonId());
            ^
In file included from C:\Users\WDAGUtilityAccount\Desktop\glslang\hlsl\hlslScanContext.cpp:52:
C:\Users\WDAGUtilityAccount\Desktop\glslang\hlsl/../glslang/MachineIndependent/preprocessor/PpContext.h:265:17: error:
      use of undeclared identifier 'snprintf'; did you mean 'vsnprintf'?
                snprintf(ppToken.name, sizeof(ppToken.name), "%s", name.c_str());
                ^~~~~~~~
                vsnprintf
C:\msys64\mingw64\x86_64-w64-mingw32\include\stdio.h:444:5: note: 'vsnprintf' declared here
int vsnprintf (char *__stream, size_t __n, const char *__format, __builtin_va_list __local_argv)
    ^
In file included from C:\Users\WDAGUtilityAccount\Desktop\glslang\hlsl\hlslScanContext.cpp:52:
C:\Users\WDAGUtilityAccount\Desktop\glslang\hlsl/../glslang/MachineIndependent/preprocessor/PpContext.h:265:68: error:
      cannot initialize a parameter of type '__builtin_va_list' with an rvalue of type 'const char *'
                snprintf(ppToken.name, sizeof(ppToken.name), "%s", name.c_str());
                                                                   ^~~~~~~~~~~~
C:\msys64\mingw64\x86_64-w64-mingw32\include\stdio.h:444:84: note: passing argument to parameter '__local_argv' here
int vsnprintf (char *__stream, size_t __n, const char *__format, __builtin_va_list __local_argv)
                                                                                   ^
9 errors generated.
mingw32-make[3]: *** [hlsl\CMakeFiles\HLSL.dir\build.make:108: hlsl/CMakeFiles/HLSL.dir/hlslScanContext.cpp.obj] Error 1
mingw32-make[2]: *** [CMakeFiles\Makefile2:1282: hlsl/CMakeFiles/HLSL.dir/all] Error 2
mingw32-make[1]: *** [CMakeFiles\Makefile2:1178: StandAlone/CMakeFiles/glslangValidator.dir/rule] Error 2
mingw32-make: *** [Makefile:610: glslangValidator] Error 2
@wumo
Copy link
Author

wumo commented Jun 4, 2020

This failure could be related to libstdc++ that I was linked to.

@johnkslang
Copy link
Member

Glslang has a switch based on MINGW_HAS_SECURE_API.

#if (defined(_MSC_VER) && _MSC_VER < 1900 /*vs2015*/) || defined MINGW_HAS_SECURE_API
    #include <basetsd.h>
    #ifndef snprintf
    #define snprintf sprintf_s

Did that value change?

@wumo
Copy link
Author

wumo commented Jun 4, 2020

@johnkslang Do you mean to add definition -DMINGW_HAS_SECURE_API=1 to cmakelists.txt? I tried, but that didn't work.

@johnkslang
Copy link
Member

I was only asking if that macro changed value somehow before and after your environment change.

@1480c1
Copy link
Contributor

1480c1 commented Jul 12, 2020

google/shaderc#1065 seems related

@johnkslang
Copy link
Member

@wumo Can you confirm whether master has this problem fix, now that #2333 is pulled in?

@wumo
Copy link
Author

wumo commented Jul 13, 2020

@johnkslang Yes, the master branch has indeed fixed this problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants