Compile ARM Assembler with Xcode 4.2 CLang?

I want to assemble arm assembly sources for the iOS with the build of
clang that comes with Apple's Xcode 4.2. All the Googling I do
indicates that all I have to do is use the ".s" extension on my
assembly sources, but that's not working for me. I think that must
have worked with previous GCC-based versions of Xcode, but it doesn't
seem to work with Xcode 4.2, which uses clang and LLVM.

I thought at first that clang only supported C, Objective-C, C++ and
Objective-C++, but "man clang" seems to indicate that it can serve as
a front-end to the assembler as well.

I'm getting some really screwy behavior when I try to assemble very
simple files. My first try "CellRun.s" had nothing but the following
in it:

.align 2

This resulted in the error message "expected identififier or (".

Somehow I managed to delete CellRun.s. When I created a new version,
I get no diagnostics at all. Suspicious about this, I inserted
several lines of clearly illegal syntax. These still did not generate
any diagnostics. The build log in the Xcode IDE didn't have any lines
for CellRun.s, so this time I don't think Xcode is attempting to
compile it at all.

I think it might work to use a Custom Build Phase but I am unclear as
to how to do that.

Thanks!

Don Quixote

Somehow I managed to delete CellRun.s. When I created a new version,
I get no diagnostics at all. Suspicious about this, I inserted
several lines of clearly illegal syntax. These still did not generate
any diagnostics. The build log in the Xcode IDE didn't have any lines
for CellRun.s, so this time I don't think Xcode is attempting to
compile it at all.

I think it might work to use a Custom Build Phase but I am unclear as
to how to do that.

I wasn't getting any diagnostics because I had created an empty Build
Phase script. I didn't see how to get rid of the script entirely, so
I removed its contents.

I fixed this by opening my project bundle's project.pbxproj file and
removing all the lines that mentioned CellRun.s. In doing so I came
across an empty build phase script, so I deleted that too. After
that, Xcode 4.2 attempted but failed to compile my assembly source.

The -x argument on clang's command line tells clang what language to
treat the source file as. Xcode 3.2.6 correctly uses "clang -x
asm-with-cpp" to assemble the source file after passing it through the
C preprocessor. Xcode 4.2 tries to compile it as Objective-C by using
"clang -x objective-c".

It looks like I have found a bug in Xcode, but I can't fathom how this
could have slipped by Apple's own iOS developers, as they write more
arm assembly code than any of us do!

I will try creating a minimal test case. If that still tries to
compile as Objective-C, I will file a bug report.

Thanks for digging into the cause here. For Xcode-related issues, please use Apple's developer forums and/or file a bug through bugreport.apple.com. We like to keep the open-source Clang mailing lists focused on the open-source Clang, and leave vendor-specific issues to vendor forums.

  - Doug

My apologies. Will do.

I'm making good progress at my ARM assembler now. When I get it
farther along I'll write a HOWTO article for my website.