[Qbs] How do I tell qbs to use the nasm assembler when building using QtCreator and a Qt kit?
Ola Røer Thorsen
ola at silentwings.no
Fri Dec 15 13:36:16 CET 2017
>
>
> > Group {
> > name: "asm-linux-x86_64"
> > condition: qbs.architecture === "x86_64"
> > files: [ ...the .asm files ]
> > cpp.assemblerName: "nasm"
> > }
>
> That's due to an implementation detail in the cpp module: The assembler
> path is read from the product-global instance, not from the per-artifact
> one. We can easily change that, but are you really using different
> assembler binaries within the same product?
>
>
Not at the same time, but I'm building this code for several platforms. It
will be deployed on x86_64 linux and windows, and on arm linux, possibly
also arm android. The arm version of this code is written in assembly that
can be built with the GNU assembler instead of nasm. That's why I wanted to
set the assembler name only in the group that had the condition
"x86_64"-architecture.
Turns out the arm version builds just fine automatically with Qbs as-is as
the file extension on those source code files is ".S" and "as" is the
assembler to use.
This particular static library I'm building here is OpenH264, and it's one
of many static libraries and applications being built in a "Project".
> > I'll have a similar Group item containing assembly code for linux armv5t
> > and yet another one for Windows, that's why I tried setting the
> > cpp.assemblerName inside the group.
>
> Within the same product? What's the final output binary then?
>
The groups are mutually exclusive, only one of them is used at a time,
depending on if I build for windows, x86_64 linux or embedded linux on arm.
>
> > Setting cpp.assemblerName outside the Group item makes qbs run nasm, but
> > then it's using some options tailored for "as" (I guess) that won't work
> > with nasm:
> > nasm: error: unrecognised option `--64'
> > type `nasm -h' for help
>
> Oh, they didn't bother to make their CLI GNU-compatible? That means it's
> not just a drop-in replacement, but something we need to support
> explicitly. Can you create a task for that at bugreports.qt.io? Ideally
> with some more information about this assembler.
>
>
No I don't think they're aiming for GNU-compatible CLI with nasm. Not even
the source code is compatible (different syntax - nasm uses the intel
syntax whereas gnu uses AT&T). https://en.wikipedia.
org/wiki/Netwide_Assembler
I'll create a task with more information.
> > At this point I'm probably better of writing my own Rule item to process
> > each of the .asm files using nasm, to have full control? (output
> artifacts
> > tagged with "obj"?)
>
> Yes, I suppose so. It's not rocket science. You need to:
> - tag your assembler files as "nasm" or something like that
> - write a Rule that
> - takes "nasm" as input
> - creates an Artifact with file tag "obj"
> - creates a Command calling the nasmn binary
> Maybe you could provide your rule as a reference implementation in the bug
> report.
>
>
Yeah I tried that yesterday and it works very well (thanks to your help
with my previous code generator problem I'm starting to get the hang of it):
Rule {
inputs: ["nasm"]
outputFileTags: ["obj"]
Artifact {
filePath: input.fileName + ".o"
fileTags: ["obj"]
}
prepare: {
var args = ["-I" + product.sourceDirectory +
"/codec/common/x86/",
"-DUNIX64",
"-o", product.buildDirectory + "/" +
input.fileName + ".o",
input.filePath,
];
var cmd = new Command("/usr/bin/nasm", args);
cmd.description = "assembling (nasm) " + input.fileName;
return [cmd];
}
}
> Alternatively, it might even suffice to do this:
> cpp.targetAssemblerFlags: [] // Or put nasm-specific stuff in here, if
> necessary
>
>
No that still kept all the regular includepaths and options, didn't work.
But the Rule solution works just fine.
Thanks,
Ola
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/qbs/attachments/20171215/0f9e5e84/attachment.html>
More information about the Qbs
mailing list