Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make prelude support nasm #652

Closed
wants to merge 5 commits into from
Closed

Conversation

zjturner
Copy link
Contributor

@zjturner zjturner commented May 15, 2024

We use a certain open source third party library which has some assembly files which can only be built with nasm. nasm has a couple of command line differences that are relevant for the purposes of getting minimal nasm support:

  1. response files don't use the syntax @foo.argsfile, rather they use the syntax -@foo.argsfile.
  2. Content of response files cannot be quoted.
  3. src file input is not prefixed with -c.

Since our toolchain now conditionally uses nasm or the default toolchain assembler, we are taking advantage of cxx_toolchain_override(). This was missing the ability to override some of the assembler arguments (e.g. we need to set compiler_type="nasm"), and also we discovered a few bugs where some fields were not null checked. So all of this is fixed in this PR.

One thing I don't entirely understand is depfiles, or if I need to do anything. nasm accepts a couple of relevant command line options, which I don't fully understand how to use

    -M            generate Makefile dependencies on stdout
    -MG           d:o, missing files assumed generated
    -MF file      set Makefile dependency file
    -MD file      assemble and generate dependencies
    -MT file      dependency target name
    -MQ file      dependency target name (quoted)
    -MP           emit phony target

I can get a .d file to generate by passing -MD /path/to/d/file -MT /path/to/obj/file but I don't know what's going to happen if I omit this. Everything seems to work for me. but maybe it's because none of my asm files depend on any other external files. Willing to investigate this further with some guidance, but the PR already works for me as is, so if people are ok with the current missing depfile support, so am I.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label May 15, 2024
@JakobDegen
Copy link
Contributor

JakobDegen commented May 19, 2024

GH says there are conflicts, could you rebase? Will import afterwards

@zjturner
Copy link
Contributor Author

Done

@facebook-github-bot
Copy link
Contributor

@JakobDegen has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@JakobDegen has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

facebook-github-bot pushed a commit to facebook/buck2-prelude that referenced this pull request May 24, 2024
Summary:
We use a certain open source third party library which has some assembly files which can only be built with [nasm](https://nasm.us/).  nasm has a couple of command line differences that are relevant for the purposes of getting minimal nasm support:

1. response files don't use the syntax `foo.argsfile`, rather they use the syntax `-@foo.argsfile`.
2. Content of response files cannot be quoted.
3. src file input is not prefixed with `-c`.

Since our toolchain now conditionally uses nasm or the default toolchain assembler, we are taking advantage of `cxx_toolchain_override()`.  This was missing the ability to override some of the assembler arguments (e.g. we need to set `compiler_type="nasm"`), and also we discovered a few bugs where some fields were not null checked.  So all of this is fixed in this PR.

One thing I don't entirely understand is depfiles, or if I need to do anything.  nasm accepts a couple of relevant command line options, which I don't fully understand how to use

```
    -M            generate Makefile dependencies on stdout
    -MG           d:o, missing files assumed generated
    -MF file      set Makefile dependency file
    -MD file      assemble and generate dependencies
    -MT file      dependency target name
    -MQ file      dependency target name (quoted)
    -MP           emit phony target
```

I can get a `.d` file to generate by passing `-MD /path/to/d/file -MT /path/to/obj/file` but I don't know what's going to happen if I omit this.  Everything seems to work for me.  but maybe it's because none of my asm files depend on any other external files.  Willing to investigate this further with some guidance, but the PR already works for me as is, so if people are ok with the current missing depfile support, so am I.

X-link: facebook/buck2#652

Reviewed By: christolliday

Differential Revision: D57592001

Pulled By: JakobDegen

fbshipit-source-id: 5b56586ae396b2d507d7bb3dab84cb6dad4e9e96
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants