We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 1244 - Inline assembly is not supported in llvm virtual machine
Summary: Inline assembly is not supported in llvm virtual machine
Status: RESOLVED WONTFIX
Alias: None
Product: SDL
Classification: Unclassified
Component: *don't know* (show other bugs)
Version: HG 2.0
Hardware: All All
: P2 enhancement
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-06 05:00 UTC by Panos Christopoulos Charitos
Modified: 2012-01-07 00:51 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Panos Christopoulos Charitos 2011-07-06 05:00:31 UTC
The LLVM's virtual machine is allergic to inline assembly that a few SDL headers have (eg SDL_endian.h)

I know that LLVM is not supported from SDL but with a little effort it could be by placing the asm code in the .c files (?probable performance issues?)
Comment 1 Ryan C. Gordon 2011-07-06 11:41:12 UTC
In what way are you using LLVM? Is this through clang? We should probably just add some #ifdefs there to use the C fallbacks.

--ryan.
Comment 2 Panos Christopoulos Charitos 2011-07-07 01:01:46 UTC
I use clang++ to create LLVM bytecode "object files" instead of ELF object files. The only extra flag I add (compared to the gcc build) is the -emit-llvm.

Then I link them using llvm-ld. The linker works just like ld without extra flags or anything and produces an LLVM bytecode executable (and a shell script to run it).

I run it using the the LLVM virtual machine (a.k.a. lli) but it fails when it finds inline asm code.

Note: The above description presents the creation and run of LLVM bytecode executables and not native ones. In native executables LLVM and clang work like a charm.

Thanks.

(In reply to comment #1)
> In what way are you using LLVM? Is this through clang? We should probably just
> add some #ifdefs there to use the C fallbacks.
> 
> --ryan.
Comment 3 Tanner Lovelace 2011-11-11 22:37:25 UTC
Note this is now affecting compilation on OS X Lion since XCode 4.2 only ships with an LLVM compiler and not a GCC compiler.

See the discussions here:

https://github.com/mxcl/homebrew/pull/7798
https://github.com/mxcl/homebrew/pull/8475
Comment 4 Sam Lantinga 2012-01-07 00:50:44 UTC
As far as I know we can't actually tell that we're going to be compiled to llvm bytecode.  Even if we fixed the SDL headers to avoid inline assembly, there's still inline assembly in SDL_cpuinfo.c that chokes lli (I checked)

I'll welcome a patch, but as far as I'm concerned this is a bug in llvm.
Actually, it IS a bug in llvm. :)
http://llvm.org/bugs/show_bug.cgi?id=1343
Comment 5 Sam Lantinga 2012-01-07 00:51:29 UTC
FYI, this doesn't affect Mac OS X Lion because their llvm compiler is compiling to native code, not being interpreted by the JIT compiler.