<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/63191>63191</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
i386 non-Windows COFF initialization
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
me-eclipse
</td>
</tr>
</table>
<pre>
Situation: we are planning to create a 32-bit COFF i386 version of LLVM/clang/etc that we will eventually use as the basis for a Compact Memory model (FAR data pointers) backend for use by our company, Gemini Computers, Inc., for use on our GEMSOS operating system.
We will not be using X86_64, only the 32-bit (and perhaps the 16-bit) objects and associated tools.
This will be a 2nd (that I can find) COFF version for llvm in the X86 machine.
My first attempt to use the stock v16 llvm indicates that initialization of COFF for non-Windows targets was not successful.
I expect to define a new vendor (gemini) and os (GEMSOS) for triples in llvm/lib/TargetParser/TargetParser.cpp.
But I thought my first step should be to try to invoke a simple target - i386-coff - and I got the following request to file (this) bug report.
eer@leap15:/usr2/llvm/LLVM-for-GEMSOS/llvm-project-llvmorg-16.0.2/build-llvm-230606/test.hello2> ls
hello.c
eer@leap15:/usr2/llvm/LLVM-for-GEMSOS/llvm-project-llvmorg-16.0.2/build-llvm-230606/test.hello2> ../bin/clang -o hello.coff.o -c -target i386-coff hello.c
fatal error: error in backend: Cannot initialize MC for non-Windows COFF object files.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: ../bin/clang -o hello.coff.o -c -target i386-coff hello.c
1. <eof> parser at end of file
#0 0x0000559b6c134f47 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (../bin/clang+0x2ea2f47)
#1 0x0000559b6c132ebe llvm::sys::RunSignalHandlers() (../bin/clang+0x2ea0ebe)
#2 0x0000559b6c1343d3 llvm::sys::CleanupOnSignal(unsigned long) (../bin/clang+0x2ea23d3)
#3 0x0000559b6c0b7c8f (anonymous namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long) CrashRecoveryContext.cpp:0:0
#4 0x0000559b6c0b7c4b (../bin/clang+0x2e25c4b)
#5 0x0000559b6c12f5a7 llvm::sys::Process::Exit(int, bool) (../bin/clang+0x2e9d5a7)
#6 0x0000559b6b0c7cc2 (../bin/clang+0x1e35cc2)
#7 0x0000559b6c0bbcf6 llvm::report_fatal_error(llvm::Twine const&, bool) (../bin/clang+0x2e29cf6)
#8 0x0000559b6c0bbbd6 (../bin/clang+0x2e29bd6)
#9 0x0000559b6be2f729 llvm::MCContext::MCContext(llvm::Triple const&, llvm::MCAsmInfo const*, llvm::MCRegisterInfo const*, llvm::MCSubtargetInfo const*, llvm::SourceMgr const*, llvm::MCTargetOptions const*, bool, llvm::StringRef) (../bin/clang+0x2b9d729)
#10 0x0000559b6b6a31ad llvm::MachineModuleInfo::MachineModuleInfo(llvm::LLVMTargetMachine const*) (../bin/clang+0x24111ad)
#11 0x0000559b6b6a3806 llvm::MachineModuleInfoWrapperPass::MachineModuleInfoWrapperPass(llvm::LLVMTargetMachine const*) (../bin/clang+0x2411806)
#12 0x0000559b6b63bd18 llvm::LLVMTargetMachine::addPassesToEmitFile(llvm::legacy::PassManagerBase&, llvm::raw_pwrite_stream&, llvm::raw_pwrite_stream*, llvm::CodeGenFileType, bool, llvm::MachineModuleInfoWrapperPass*) (../bin/clang+0x23a9d18)
#13 0x0000559b6c8b992c clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>) (../bin/clang+0x362792c)
#14 0x0000559b6ccd8e51 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) CodeGenAction.cpp:0:0
#15 0x0000559b6ddafd1e clang::ParseAST(clang::Sema&, bool, bool) (../bin/clang+0x4b1dd1e)
#16 0x0000559b6cc0d849 clang::FrontendAction::Execute() (../bin/clang+0x397b849)
#17 0x0000559b6cb83636 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (../bin/clang+0x38f1636)
#18 0x0000559b6ccd2eaa clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (../bin/clang+0x3a40eaa)
#19 0x0000559b6b0c77ba cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (../bin/clang+0x1e357ba)
#20 0x0000559b6b0c43a5 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#21 0x0000559b6ca06ec2 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::$_1>(long) Job.cpp:0:0
#22 0x0000559b6c0b7c26 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (../bin/clang+0x2e25c26)
#23 0x0000559b6ca06724 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (../bin/clang+0x3774724)
#24 0x0000559b6c9ca794 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (../bin/clang+0x3738794)
#25 0x0000559b6c9ca9ce clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (../bin/clang+0x37389ce)
#26 0x0000559b6c9e7c30 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (../bin/clang+0x3755c30)
#27 0x0000559b6b0c36e8 clang_main(int, char**) (../bin/clang+0x1e316e8)
#28 0x00007fae4276124d __libc_start_main (/lib64/libc.so.6+0x3524d)
#29 0x0000559b6b0c03aa _start /home/abuild/rpmbuild/BUILD/glibc-2.31/csu/../sysdeps/x86_64/start.S:122:0
clang-16: error: clang frontend command failed with exit code 70 (use -v to see invocation)
clang version 16.0.2 (git@github.com:GEMSOS/LLVM-for-GEMSOS.git 9993b978495a04334fe0b9e58af8d4465a6dbdae)
Target: i386-unknown-unknown-coff
Thread model: posix
InstalledDir: /usr2/llvm/LLVM-for-GEMSOS/llvm-project-llvmorg-16.0.2/build-llvm-230606/test.hello2/../bin
clang-16: note: diagnostic msg:
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-16: note: diagnostic msg: /tmp/hello-dee9a3.c
clang-16: note: diagnostic msg: /tmp/hello-dee9a3.sh
clang-16: note: diagnostic msg:
********************
eer@leap15:/usr2/llvm/LLVM-for-GEMSOS/llvm-project-llvmorg-16.0.2/build-llvm-230606/test.hello2> cp /tmp/hello-dee9a3.* .
eer@leap15:/usr2/llvm/LLVM-for-GEMSOS/llvm-project-llvmorg-16.0.2/build-llvm-230606/test.hello2> ls
hello.c hello-dee9a3.c hello-dee9a3.sh
eer@leap15:/usr2/llvm/LLVM-for-GEMSOS/llvm-project-llvmorg-16.0.2/build-llvm-230606/test.hello2> more *.sh
# Crash reproducer for clang version 16.0.2 (git@github.com:GEMSOS/LLVM-for-GEMSOS.git 9993b978495a04334fe0b9e58af8d4465a6dbdae)
# Driver args: "-o" "hello.coff.o" "-c" "-target" "i386-coff" "hello.c"
# Original command: "/usr2/llvm/LLVM-for-GEMSOS/llvm-project-llvmorg-16.0.2/build-llvm-230606/bin/clang-16" "-cc1" "-triple" "i386-unknown-unknown-coff" "-emit-obj" "-mrelax-all" "-disable-free" "-clear-ast-before-backend" "-disable-llvm-verifier" "-discard-value-names
" "-main-file-name" "hello.c" "-mrelocation-model" "static" "-mframe-pointer=all" "-fmath-errno" "-ffp-contract=on" "-fno-rounding-math" "-mconstructor-aliases" "-funwind-tables=2" "-target-cpu" "pentium4" "-tune-cpu" "generic" "-mllvm" "-treat-scalable-fixed-error-as-w
arning" "-debugger-tuning=gdb" "-fcoverage-compilation-dir=/usr2/llvm/LLVM-for-GEMSOS/llvm-project-llvmorg-16.0.2/build-llvm-230606/test.hello2" "-resource-dir" "/usr2/llvm/LLVM-for-GEMSOS/llvm-project-llvmorg-16.0.2/build-llvm-230606/lib/clang/16" "-fdebug-compilation-
dir=/usr2/llvm/LLVM-for-GEMSOS/llvm-project-llvmorg-16.0.2/build-llvm-230606/test.hello2" "-ferror-limit" "19" "-fgnuc-version=4.2.1" "-fcolor-diagnostics" "-faddrsig" "-o" "hello.coff.o" "-x" "c" "hello.c"
"/usr2/llvm/LLVM-for-GEMSOS/llvm-project-llvmorg-16.0.2/build-llvm-230606/bin/clang-16" "-cc1" "-triple" "i386-unknown-unknown-coff" "-emit-obj" "-mrelax-all" "-disable-free" "-clear-ast-before-backend" "-disable-llvm-verifier" "-discard-value-names" "-main-file-name"
"hello.c" "-mrelocation-model" "static" "-mframe-pointer=all" "-fmath-errno" "-ffp-contract=on" "-fno-rounding-math" "-mconstructor-aliases" "-funwind-tables=2" "-target-cpu" "pentium4" "-tune-cpu" "generic" "-mllvm" "-treat-scalable-fixed-error-as-warning" "-debugger-t
uning=gdb" "-fcoverage-compilation-dir=/usr2/llvm/LLVM-for-GEMSOS/llvm-project-llvmorg-16.0.2/build-llvm-230606/test.hello2" "-fdebug-compilation-dir=/usr2/llvm/LLVM-for-GEMSOS/llvm-project-llvmorg-16.0.2/build-llvm-230606/test.hello2" "-ferror-limit" "19" "-fgnuc-versi
on=4.2.1" "-fcolor-diagnostics" "-faddrsig" "-x" "c" "hello-dee9a3.c"
eer@leap15:/usr2/llvm/LLVM-for-GEMSOS/llvm-project-llvmorg-16.0.2/build-llvm-230606/test.hello2> more *.c
::::::::::::::
hello.c
::::::::::::::
int my_printf(const char *);
int main() {
return(my_printf("hello, world\n"));
}
::::::::::::::
hello-dee9a3.c
::::::::::::::
# 1 "<built-in>"
# 1 "hello.c"
int my_printf(const char *);
int main() {
return(my_printf("hello, world\n"));
}
eer@leap15:/usr2/llvm/LLVM-for-GEMSOS/llvm-project-llvmorg-16.0.2/build-llvm-230606/test.hello2>
[test.hello2.zip](https://github.com/llvm/llvm-project/files/11688786/test.hello2.zip)
I'm also attaching the bugpoint-reduced-simplified.bc, as requested.
[bugpoint-files.zip](https://github.com/llvm/llvm-project/files/11688957/bugpoint-files.zip)
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsW11z2zbW_jX0DYYaEaQo8sIXimyl6SSvM7G73TsPCBxK2IAAFwD9sb_-HQCkRMqy3LTppjNbj1tL-DrPec7BOfgKMYZvJcBltHgXLa4uSGd3Sl82EAMVvDVwUSn2fHnLbUcsVzJKV-gRENGAWkGk5HKLrEJUA7GACEpxXHGL1jebDeJpkaMH0IYriVSNPn78x6cIb6ggchvhDViK7I5YN94jFwLBA0jbESGeUWcAEYPsDlBFDDeoVhoRtFZNS6hFn6BR-hk1ioFAES42qy-IEUtQq7i0oE2ES1QR-hUk813deNUzUp1G1I0hnyO8Ru-h4ZL7UbvQa40-SDpzf4deDnqn0fvrT7c3t0i1oIl1SptnY6GZRfOraL4K__-110MqiypAnXHt_lnk93nmRlRSPHuNeo4iXBDJUAt6R9qga5K7GgdeVf8Cag1yLYgxinJigSGrlDAToXc7boLYyvGPJXMDe14_IEokqrlkbkRvksEaTjshHhrEpRf8zyJHDaE7LmEy-qdnVHNtLCLWQtNaZ2vHiutjrKJf0UOSDyMxTokFE4zKJbecCP4f7zbO_B6AEyyVjH_lkqlHgyzRW7AGPRLjeTMdpWBM3YkJjg8InlqgXj6Dmkunq4RH9ACSKe1U3npjOk0dZ8q4smA1V-bkWs1bAcbp7BBHeCN4FeHNncfwmWgD-ujrjLbtBMi7zvFqd6rb7ixqBnqMhRaZneoEc3awCln97P5w-aC-OrCGN62AXl8U-8kRU1XXKPaAP6Ctsp7XWgmhHp3vaPh3B8YrXXMBwbA8OHfnqlul7QQegI6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