shader-slang / slang

Making it easier to work with shaders
MIT License
1.78k stars 159 forks source link

slanc fails silently if host prelude doesn't compile #2830

Open expipiplus1 opened 1 year ago

expipiplus1 commented 1 year ago

For example, put the following in prelude/slang-cpp-host-prelude.h

#if defined(__SLANG_COMPILER__)
#error
#endif 

Make and run the following command

./bin/linux-x64/debug/slangc tests/bugs/interface-lvalue.slang -o a.exe

Observe that this finishes with exit code 0 and nothing on stderr, however a.exe is not created.

expipiplus1 commented 1 year ago

After a cursory look, it seems that GCCDownstreamCompilerUtil::parseOutput, hence CommandLineDownstreamCompiler::compile fails.

The error is converted to a nullptr return by TargetProgram::_createWholeProgramResult and then ignored by EndToEndCompileRequest::generateOutput

Because the gcc output parsing failed there are no diagnostics, so the check if (getSink()->getErrorCount() != 0) doesn't detect any errors.

expipiplus1 commented 1 year ago

We should have a --verbose option to say what we're calling downstream compilers with, and what their output is.

natduca commented 7 months ago

Silent failures bad, language hardening, Q3.