-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
It is not possible to get .asm files handled as assembly with C preprocessor files #4856
Comments
cc @meteorcloudy |
Yes, I believe this will eventually be solved by making the extensions configurable on different platforms. |
Sounds good, is there time plan for it? |
@burkpojken I'm planning to make it happen next quarter |
Ok thanks for info, then we will use our patched version until then |
@burkpojken Which patch did you apply to Bazel to make this work? |
The problem is that .asm files are not handled as preprocess-assemble, so if the .asm files use include it will not be rebuilt even if a header file is changed. |
To be clearer I changed in CppFileTypes.java public static final FileType ASSEMBLER_WITH_C_PREPROCESSOR = And removed the ".asm" part in |
@burkpojken Thanks! |
Any progress on this? |
@mhlopko Is it going to be easier to configure extensions of input files after we migrate cc rules to Skylark? Because currently we can only configure extensions of output files of Bazel in CROSSTOOL, which doesn't cover this use case. |
Nope, that won't help, I was hoping your work on configuring extensions for windows will cover it. So it stays as a separate feature request, with a genrule doing the renaming as a workaround. |
I work in the same group as burkpojken. I can try to implement this in bazel, but I need some help to find a proper solution. As burkpojken said, the problem is that the following assembly file extensions are hard-coded in bazel:
All our hand-written assembly files use file extension ".asm". They need to be preprocessed. It is not feasible for us to rename all these files from ".asm" to ".S". (mhlopko's workaround, to use a genrule to rename the files, would work but is a bit ugly.) The simplest solution is to use our current patch, where we just hard-code that ".asm" files should be preprocessed. But can we push such a patch upstreams? Then all ".asm" files will be preprocessed, unnecessarily for other users as their ".asm" files do not contain any preprocessor directives. A better solution is probably to make it possible to set which file extensions to preprocess in the CROSSTOOL file. Do you have any proposal of the syntax of this new setting? |
This breaks quite a bit of Google, so this change as is would have to go through the incompatible change process. But we do have a way to specify extensions in the CROSSTOOL (artifact name patterns). But apparently we don't use them for assembly :/ |
Aha. I am a bit surprised to hear that it broke internal tests at Google. The output from the preprocessor should be the same as the input, if the .asm files do not contain any preprocesor directives, so I thought that the only difference would be a slight performance hit. Anyway, I agree that making this configurable in CROSSTOOL is a good idea. Do you have any suggestion on how to use the artifact name patterns message to configure this? I can try to implement it in Bazel. |
I think it is not really consequent how this is implemented in Bazel today. But this is not regarded since action: 'assemble', will not produce a .d file, the flags above are not used, because of the hardcoded handling in bazel for ".S" and ".s" So Does not work as expected I would say in this case. Maybe we could change the actions to Add an additional Remove the default for action: 'assemble' (or with the new name action: 'assemble-s-files'? |
@hlopko, what is your opinion on the way forward? You wrote in a comment to the pull request that it will be included in Bazel 0.22.0. A suggestion is that you submit this PR and that we close this ticket, but write a new ticket on making this configurable in CROSSTOOL. |
I work together with @emusand and @burkpojken. The reason for this change is that we have realized that the list CppFileTypes.ASSEMBLER_WITH_C_PREPROCESSOR does not mean "run the preprocessor for these files", but instead "assume that these files will be preprocessed". Therefore just moving ".asm" to this list works in our internal environment because we are using a compiler that supports preprocessing of ".asm" files but users with compilers that are not supporting this (for example GCC and Clang) will experience build failures like this We are proposing a new approach to solving this where we add a new field in the toolchain definition, to tell bazel if the compiler will preprocess ".asm" files or not. What do you think of this? |
We think the right way forward is to add a list argument, preprocess_assembler_filename_extensions (or something shorter), to the function create_cc_toolchain_config_info with a default value of [".S"]. We then propagate the value of preprocess_assembler_filename_extensions to CppFileTypes to decide the value of the lists ASSEMBLER_WITH_C_PREPROCESSOR and ASSEMBLER. This would allow us to specify that our compiler should preprocess .asm files while not breaking anything for users with other compilers since the default value suits them. Adding the new argument seems easy enough. I think the hard part is to share the value of preprocess_assembler_filename_extensions with CppFileTypes so any suggestions on how this could be implemented would be much appreciated. |
/cc Our C++ rule expert @oquenchil |
The issue is that we still need to propagate the value of the list with what files that is to be preprocessed from CcToolchainConfigInfo to CppFileTypes. The value of this list is needed / requested in CppFileTypes from various other objects already before this list possibly could be propagated from CcToolchainConfigInfo, i.e there hasn't been any object of CcToolchainConfigInfo created before the information is needed in CppFileTypes. To only propagate the value is therefore not enough to fix this issue, a major redesign is required.
|
any progress ?our team have a lot of hand written .asm file |
Unfortunately this work is parked for now. ehrtro, ehkloaj and I did a serious attempt to implement this in a proper way last summer, but realized that it was more work than we expected. Now we are using our own local patch that just handles .asm files in the same way as .S files, that is we just adds ".asm" to the list of filename extensions that Bazel expects to be preprocessed. This works for us as our proprietary assembler always preprocesses .asm files, but it does not work when compiling with gcc or clang. |
Sorry, we currently don't have the bandwidth to address this issue, but a contribution to fix is always welcome. |
Thanks for reply @emusand @meteorcloudy |
Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 2+ years. It will be closed in the next 14 days unless any other activity occurs or one of the following labels is added: "not stale", "awaiting-bazeler". Please reach out to the triage team ( |
This issue has been automatically closed due to inactivity. If you're still interested in pursuing this, please reach out to the triage team ( |
Feature requests:
In our big projects we use our own tool chain.
Unfortunately all our hand written assembly files are named .asm instead of .S
Bazel handles .asm as .s files (lower case s) and then they are not seen as preprocessed and no .d file is requested.
Our .asm files can use #include and then the target is not rebuilt when a dependent .h file is changed.
I is a big thing for us to rename all .asm files since there are very many files in many different projects and repos. There are also tools that depend on the .asm extension.
We have patched bazel to handle the .asm files as .S files to make it work now but we would rather have the support in the official bazel releases.
We have tried with the following added to our CROSSTOOL file but the feature is ignored by bazel for the assembly files
feature {
name: 'dependency_file'
flag_set {
action: 'assemble'
action: 'preprocess-assemble'
action: 'c-compile'
action: 'c++-compile'
action: 'c++-module-compile'
action: 'objc-compile'
action: 'objc++-compile'
action: 'c++-header-preprocessing'
action: 'c++-header-parsing'
action: 'clif-match'
expand_if_all_available: 'dependency_file'
flag_group {
flag: '-MD'
flag: '-MF'
flag: '%{dependency_file}'
}
}
}
We use:
Host operating system: Linux
Bazel version: 0.10.1 with patches for the above
The text was updated successfully, but these errors were encountered: