google / DirectXShaderCompiler

This repo hosts the source for the DirectX Shader Compiler which is based on LLVM/Clang.
Other
52 stars 11 forks source link

Issue compiling with Alpine Linux and GCC 6.4 #253

Closed gwihlidal closed 6 years ago

gwihlidal commented 6 years ago

Hello!

I'm running into issues compiling DXC on Linux (alpine 3.7) using GCC 6.4.0; there are quite a number of redefinitions throwing errors like the fopen one shown below.

[174/1153] Building CXX object lib/Transforms/Scalar/CMakeFiles/LLVMScalarOpts.dir/MemCpyOptimizer.cpp.o
FAILED: lib/Transforms/Scalar/CMakeFiles/LLVMScalarOpts.dir/MemCpyOptimizer.cpp.o
/usr/bin/c++  -DENABLE_SPIRV_CODEGEN -DSUPPORT_QUERY_GIT_COMMIT_INFO -D_ITERATOR_DEBUG_LEVEL=0 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Ilib/Transforms/Scalar -I../lib/Transforms/Scalar -Iinclude -I../include -Iinclude/dxc/Tracing -fPIC -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-unknown-pragmas -fdiagnostics-color -std=c++11 -Wno-missing-field-initializers -pedantic -Wno-long-long -Wno-maybe-uninitialized -Wnon-virtual-dtor -Wno-comment -std=c++11 -ffunction-sections -fdata-sections -O3 -DNDEBUG -MD -MT lib/Transforms/Scalar/CMakeFiles/LLVMScalarOpts.dir/MemCpyOptimizer.cpp.o -MF lib/Transforms/Scalar/CMakeFiles/LLVMScalarOpts.dir/MemCpyOptimizer.cpp.o.d -o lib/Transforms/Scalar/CMakeFiles/LLVMScalarOpts.dir/MemCpyOptimizer.cpp.o -c ../lib/Transforms/Scalar/MemCpyOptimizer.cpp
In file included from ../include/llvm/Analysis/TargetLibraryInfo.h:35:0,
                 from ../lib/Transforms/Scalar/MemCpyOptimizer.cpp:21:
../include/llvm/Analysis/TargetLibraryInfo.def:435:26: error: redefinition of 'fopen'
 TLI_DEFINE_ENUM_INTERNAL(fopen64)
/dxc/build # cat ../utils/cmake-predefined-config-params
-DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=ON -DLLVM_APPEND_VC_REV:BOOL=ON -DLLVM_DEFAULT_TARGET_TRIPLE:STRING=dxil-ms-dx -DLLVM_ENABLE_EH:BOOL=ON -DLLVM_ENABLE_RTTI:BOOL=ON -DLLVM_INCLUDE_DOCS:BOOL=OFF -DLLVM_INCLUDE_EXAMPLES:BOOL=OFF -DLLVM_INCLUDE_TESTS:BOOL=OFF -DLLVM_OPTIMIZED_TABLEGEN:BOOL=OFF -DLLVM_REQUIRES_EH:BOOL=ON -DLLVM_REQUIRES_RTTI:BOOL=ON -DLLVM_TARGETS_TO_BUILD:STRING=None -DLIBCLANG_BUILD_STATIC:BOOL=ON -DCLANG_BUILD_EXAMPLES:BOOL=OFF -DCLANG_CL:BOOL=OFF -DCLANG_ENABLE_ARCMT:BOOL=OFF -DCLANG_ENABLE_STATIC_ANALYZER:BOOL=OFF -DCLANG_INCLUDE_TESTS:BOOL=OFF -DHLSL_INCLUDE_TESTS:BOOL=ON -DENABLE_SPIRV_CODEGEN:BOOL=ON

Has this been encountered before?

Thanks! Graham

ehsannas commented 6 years ago

I haven't seen this error. Our Linux buildbot is currently passing using GCC 4.8.4 5.4.0

Latest run: https://travis-ci.org/google/DirectXShaderCompiler/jobs/396519461

We haven't tried other GCC versions. Will try to investigate soon.

gwihlidal commented 6 years ago

Sounds good! I just released a Dockerfile (referenced above) that can repro the issue, and also includes the full build log. In the meantime I will try with an Ubuntu base image.

ehsannas commented 6 years ago

Feel free to poke around and if you find out the reason for failure, please feel free to post a pull-request to the google repo.

gwihlidal commented 6 years ago

Possibly related:

pow2clk commented 6 years ago

I periodically compile with gcc-6.4. I've never seen this issue.

Our buildbot builds with gcc 5.4.0. Not 4.8.4. 4.8.4 support is impossible because of insufficient c++11 support.

ehsannas commented 6 years ago

Oops, I was looking at the wrong log file. You're right.

gwihlidal commented 6 years ago

Confirmed that using Ubuntu (18.04 in my case) works fine, so the issue is likely specific to Alpine Linux

pow2clk commented 6 years ago

Just typing "ninja" will try to compile everything. Sadly, that doesn't work yet. you can compile dxc and clang-spirv-tests. Try just typing "ninja dxc clang-spirv-tests"

ehsannas commented 6 years ago

@pow2clk , Actually I recently merged a change that allows you to just run ninja.

So, @gwihlidal should be fine. The documentation file is also updated and tells users to just run ninja

pow2clk commented 6 years ago

Give this a try: https://github.com/pow2clk/DirectXShaderCompiler/tree/alpine64

To use from your already cloned DirectXShaderCompiler location: git remote add p2c https://github.com/pow2clk/DirectXShaderCompiler.git git fetch p2c git checkout -b alpine64 -t p2c/alpine64 then try rebuilding. It needn't be a clean rebuild.

pow2clk commented 6 years ago

Sorry if I'm spoonfeeding excessively. I try not to assume git familiarity levels.

gwihlidal commented 6 years ago

Thanks, @pow2clk - I can confirm that your branch does in fact fix the errors! :)

ehsannas commented 6 years ago

Woohoo! \o/ Thanks @pow2clk