-
Notifications
You must be signed in to change notification settings - Fork 797
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
[multitop] Add better support for linker scripts (preprocessing) #25908
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've gone over the Bazel part a couple of times and it looks good. Nice to see the get_tool_for_action
used. (aside, I realised that I missed this for the other part of our repo that uses the preprocessor here: rules/ujson.bzl#L40).
I think this is better than using Bazel substitution as discussed in the other PR.
LGTM, thanks
Signed-off-by: Amaury Pouly <[email protected]>
c24080a
to
9683aeb
Compare
9683aeb
to
5ac9ac0
Compare
One thing to note about this PR which may be confusing: it gives two ways to include files: |
Signed-off-by: Amaury Pouly <[email protected]>
With this commit, linker script files are now preprocessed. The is handled similarly to `cc_library`: if `ld_library` is used with only files in `includes`, then it simply adds them to the compilation context. If `ld_library` is used with `script` set, then the file with be preprocessed with the compilation context constructed from its dependencies. This commit also adds a `defines` attribute to the `ld_library` so that defines can be set in bazel BUILD files. Signed-off-by: Amaury Pouly <[email protected]>
This avoid including by mistake the wrong file: because it is marked as incompatible, it will fail to compile. Signed-off-by: Amaury Pouly <[email protected]>
Each top has a different top linker file name. When dependencies switch to multitop, then need to INCLUDE the correct file. This commit adds a define OPENTITAN_TOP_MEMORY_LD which is set to the file name so that user can do INCLUDE OPENTITAN_TOP_MEMORY_LD Signed-off-by: Amaury Pouly <[email protected]>
The OPENTITAN_TOP_MEMORY_LD define is set in each top's linker library target. Signed-off-by: Amaury Pouly <[email protected]>
5ac9ac0
to
d903a15
Compare
Alternative approach to #25785 that preprocesses linker scripts instead of using bazel templates.
For now, this PR choses the "easy" way of keep each's top linker file name and set a defines so that users that include the correct file without knowing the name. An alternative approach would be to rename the file so it's the same for all tops. Note that even renaming would not render the preprocess useless because further multitop changes down the line cannot be handled by just renaming.
Annoyance: I couldn't make
cc_common.compile
to work because it does not add anything to thecout
output so one can't get the output file... I had to resort to manually run the compiler, I don't know if there is an easier way to do that. It's probably semi-overkill because for the purpose of preprocessing linker script, it's very unlikely that the environment or system includes will play any role but at least it's the "textbook" way of doing it.