Luís Marques via llvm-dev
2017-Jul-05 23:50 UTC
[llvm-dev] MSP430 code generation from LLVM IR
Hello, While trying to find out why the LDC compiler refuses to generate object code for MSP430 targets (but generates MSP430 assembly or LLVM IR/bitcode), I came across the following apparent inconsistency. This works: $ clang --target=msp430 -c test.c This doesn't work: $ clang --target=msp430 -S -emit-llvm test.c $ llc -filetype=obj test.ll /opt/msp430/bin/llc: target does not support generation of this file type! That sequence works fine for x86. Could someone help shed some light into this discrepancy? (Maybe it will also help me figure out why LDC refuses to directly generate MSP430 object files [1]). Thanks, Luís [1] $ ldc2 -mtriple=msp430 -c test.d no support for asm output UNREACHABLE executed at ../driver/toobj.cpp:130! 0 ldc2 0x0000000107e19c9c llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 60 1 ldc2 0x0000000107e1a1e9 PrintStackTraceSignalHandler(void*) + 25 2 ldc2 0x0000000107e16139 llvm::sys::RunSignalHandlers() + 425 3 ldc2 0x0000000107e1a642 SignalHandler(int) + 354 4 libsystem_platform.dylib 0x00007fffa0ad5b3a _sigtramp + 26 5 libsystem_platform.dylib 0x0000000000000003 _sigtramp + 1599251683 6 libsystem_c.dylib 0x00007fffa095a420 abort + 129 7 ldc2 0x0000000107d246c0 LLVMInstallFatalErrorHandler + 0 8 ldc2 0x0000000105efd2a7 codegenModule(llvm::TargetMachine&, llvm::Module&, llvm::raw_fd_ostream&, llvm::TargetMachine::CodeGenFileType) + 391 9 ldc2 0x0000000105f00ab9 (anonymous namespace)::writeObjectFile(llvm::Module*, char const*) + 377 10 ldc2 0x0000000105efcc05 writeModule(llvm::Module*, char const*) + 10517 11 ldc2 0x0000000105ee6162 ldc::CodeGenerator::writeAndFreeLLModule(char const*) + 1602 12 ldc2 0x0000000105ee6a82 ldc::CodeGenerator::finishLLModule(Module*) + 130 13 ldc2 0x0000000105ee880c ldc::CodeGenerator::emit(Module*) + 1420 14 ldc2 0x0000000105f36e4e codegenModules(Array<Module*>&) + 574 15 ldc2 0x0000000105bf2a00 mars_mainBody(Array<char const*>&, Array<char const*>&) + 5120 Abort trap: 6 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170706/3362f149/attachment-0001.html>
Anton Korobeynikov via llvm-dev
2017-Jul-06 00:25 UTC
[llvm-dev] MSP430 code generation from LLVM IR
There is no direct object emission support in MSP430 backend. clang executed assembler under the hood. On Thu, Jul 6, 2017 at 2:50 AM, Luís Marques via llvm-dev <llvm-dev at lists.llvm.org> wrote:> Hello, > > While trying to find out why the LDC compiler refuses to generate object > code for MSP430 targets (but generates MSP430 assembly or LLVM IR/bitcode), > I came across the following apparent inconsistency. > > This works: > > $ clang --target=msp430 -c test.c > > This doesn't work: > > $ clang --target=msp430 -S -emit-llvm test.c > $ llc -filetype=obj test.ll > /opt/msp430/bin/llc: target does not support generation of this file type! > > That sequence works fine for x86. > > Could someone help shed some light into this discrepancy? (Maybe it will > also help me figure out why LDC refuses to directly generate MSP430 object > files [1]). > > Thanks, > Luís > > [1] $ ldc2 -mtriple=msp430 -c test.d > no support for asm output > UNREACHABLE executed at ../driver/toobj.cpp:130! > 0 ldc2 0x0000000107e19c9c > llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 60 > 1 ldc2 0x0000000107e1a1e9 > PrintStackTraceSignalHandler(void*) + 25 > 2 ldc2 0x0000000107e16139 > llvm::sys::RunSignalHandlers() + 425 > 3 ldc2 0x0000000107e1a642 SignalHandler(int) + 354 > 4 libsystem_platform.dylib 0x00007fffa0ad5b3a _sigtramp + 26 > 5 libsystem_platform.dylib 0x0000000000000003 _sigtramp + 1599251683 > 6 libsystem_c.dylib 0x00007fffa095a420 abort + 129 > 7 ldc2 0x0000000107d246c0 LLVMInstallFatalErrorHandler > + 0 > 8 ldc2 0x0000000105efd2a7 > codegenModule(llvm::TargetMachine&, llvm::Module&, llvm::raw_fd_ostream&, > llvm::TargetMachine::CodeGenFileType) + 391 > 9 ldc2 0x0000000105f00ab9 (anonymous > namespace)::writeObjectFile(llvm::Module*, char const*) + 377 > 10 ldc2 0x0000000105efcc05 writeModule(llvm::Module*, > char const*) + 10517 > 11 ldc2 0x0000000105ee6162 > ldc::CodeGenerator::writeAndFreeLLModule(char const*) + 1602 > 12 ldc2 0x0000000105ee6a82 > ldc::CodeGenerator::finishLLModule(Module*) + 130 > 13 ldc2 0x0000000105ee880c > ldc::CodeGenerator::emit(Module*) + 1420 > 14 ldc2 0x0000000105f36e4e > codegenModules(Array<Module*>&) + 574 > 15 ldc2 0x0000000105bf2a00 mars_mainBody(Array<char > const*>&, Array<char const*>&) + 5120 > Abort trap: 6 > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >-- With best regards, Anton Korobeynikov Department of Statistical Modelling, Saint Petersburg State University
Nicholas Wilson via llvm-dev
2017-Jul-06 00:35 UTC
[llvm-dev] MSP430 code generation from LLVM IR
Luís, try using the -no-integrated-as flag to execute the assembler for you. We should probably make that the default for MSP430. Nic On 6 Jul 2017, at 7:50 am, Luís Marques via llvm-dev <llvm-dev at lists.llvm.org<mailto:llvm-dev at lists.llvm.org>> wrote: Hello, While trying to find out why the LDC compiler refuses to generate object code for MSP430 targets (but generates MSP430 assembly or LLVM IR/bitcode), I came across the following apparent inconsistency. This works: $ clang --target=msp430 -c test.c This doesn't work: $ clang --target=msp430 -S -emit-llvm test.c $ llc -filetype=obj test.ll /opt/msp430/bin/llc: target does not support generation of this file type! That sequence works fine for x86. Could someone help shed some light into this discrepancy? (Maybe it will also help me figure out why LDC refuses to directly generate MSP430 object files [1]). Thanks, Luís [1] $ ldc2 -mtriple=msp430 -c test.d no support for asm output UNREACHABLE executed at ../driver/toobj.cpp:130! 0 ldc2 0x0000000107e19c9c llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 60 1 ldc2 0x0000000107e1a1e9 PrintStackTraceSignalHandler(void*) + 25 2 ldc2 0x0000000107e16139 llvm::sys::RunSignalHandlers() + 425 3 ldc2 0x0000000107e1a642 SignalHandler(int) + 354 4 libsystem_platform.dylib 0x00007fffa0ad5b3a _sigtramp + 26 5 libsystem_platform.dylib 0x0000000000000003 _sigtramp + 1599251683 6 libsystem_c.dylib 0x00007fffa095a420 abort + 129 7 ldc2 0x0000000107d246c0 LLVMInstallFatalErrorHandler + 0 8 ldc2 0x0000000105efd2a7 codegenModule(llvm::TargetMachine&, llvm::Module&, llvm::raw_fd_ostream&, llvm::TargetMachine::CodeGenFileType) + 391 9 ldc2 0x0000000105f00ab9 (anonymous namespace)::writeObjectFile(llvm::Module*, char const*) + 377 10 ldc2 0x0000000105efcc05 writeModule(llvm::Module*, char const*) + 10517 11 ldc2 0x0000000105ee6162 ldc::CodeGenerator::writeAndFreeLLModule(char const*) + 1602 12 ldc2 0x0000000105ee6a82 ldc::CodeGenerator::finishLLModule(Module*) + 130 13 ldc2 0x0000000105ee880c ldc::CodeGenerator::emit(Module*) + 1420 14 ldc2 0x0000000105f36e4e codegenModules(Array<Module*>&) + 574 15 ldc2 0x0000000105bf2a00 mars_mainBody(Array<char const*>&, Array<char const*>&) + 5120 Abort trap: 6 _______________________________________________ LLVM Developers mailing list llvm-dev at lists.llvm.org<mailto:llvm-dev at lists.llvm.org> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170706/01ea6d2c/attachment.html>
Luís Marques via llvm-dev
2017-Jul-06 00:51 UTC
[llvm-dev] MSP430 code generation from LLVM IR
On Thu, Jul 6, 2017 at 1:35 AM, Nicholas Wilson < iamthewilsonator at hotmail.com> wrote:> Luís, try using the -no-integrated-as flag to execute the assembler for > you. > We should probably make that the default for MSP430. >Cool. When I did that on macOS, LDC generated a lot of complaints, possibly because it is assuming mach-o files. I tried changing from -mtriple=msp430 to -mtriple=msp430-unknown-elf, to no avail. E.g.: $ ldc2 -mtriple=msp430-unknown-elf -c -no-integrated-as qosd.d ldc-ad1c8f0.s:3:11: error: mach-o section specifier requires a segment whose length is between 1 and 16 characters .section .text._D4qosd3fooFZi,"axG", at progbits,_D4qosd3fooFZi,comdat ^ ldc-ad1c8f0.s:6:2: error: unknown directive .type _D4qosd3fooFZi, at function ^ ldc-ad1c8f0.s:8:2: error: invalid instruction mnemonic 'mov.w' mov.w #42, r14 ^~~~~ (...) I didn't try it in a Linux host. I imagine a lot of the errors will go away there (because it assumes ELF), but possibly not the ones about 'mov.w'. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170706/167445bc/attachment.html>