Where to emit an undefined fltused symbol if floating point is used?

While working on porting the large test-suite over to lit and running
it on Windows I've discovered a major problem with COFF emission. Any
test that uses floating point instructions currently fails with the
integrated assembler with:

runtime error R6002
- floating point support not loaded

A quick look with nm shows that MSVC emits an undefined __fltused
symbol if _any_ floating point instructions are used. I think this is
required for the kernel to save the floating point registers, and thus
the Microsoft C runtime complains if you use floating point without

The attached code duplicates this failure when compiled with (on Windows):
% clang -O3 2002-05-02-ArgumentTest.c
% 2002-05-02-ArgumentTest.exe

The attached code works when compiled as:
% clang -O3 -c SingleSource\UnitTests\2002-05-02-ArgumentTest.c
% link 2002-05-02-ArgumentTest.o libcmt.lib -include:__fltused
% 2002-05-02-ArgumentTest.exe
12, 1.245000, 120, 123456677890, -10, 4500000000000000.000000

My question is where should the code that emits this symbol live? I
would assume someplace in the x86 codegen in case the optimizers are
somehow able to remove the instructions. And I would prefer someplace
before COFF emission.

The last, and slightly embarrassing question, is exactly how do you
add the symbol? I looked around at the API's but couldn't figure out
an easy way to simply add an undefined symbol.


- Michael Spencer

2002-05-02-ArgumentTest.ll (1.03 KB)

2002-05-02-ArgumentTest.s (1.32 KB)