[Qbs] How do I tell qbs to use the nasm assembler when building using QtCreator and a Qt kit?

Christian Kandeler christian.kandeler at qt.io
Fri Dec 15 10:07:33 CET 2017

On Thu, 14 Dec 2017 21:01:03 +0100
Ola Røer Thorsen <ola at silentwings.no> wrote:

> > You need to set cpp.assemblerName, either in the profile or in your
> > product(s).
> >  
> Right. I had only tried setting it inside the Group item, but that didn't
> have any effect. I need another Properties item instead to conditionally
> set the cpp.assemblerName then?
> 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?

> 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?

> 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.

> 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.

Alternatively, it might even suffice to do this:
    cpp.targetAssemblerFlags: [] // Or put nasm-specific stuff in here, if necessary


More information about the Qbs mailing list