-
Notifications
You must be signed in to change notification settings - Fork 813
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 (templating) #25785
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.
The rule changes LGTM, thanks
62c9259
to
233173e
Compare
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.
This looks good to me!
233173e
to
31e79ff
Compare
Signed-off-by: Amaury Pouly <[email protected]>
Linker files are not preprocessed, which makes it hard to support several tops. In particular, including different files based on the top, or using a different region is very difficult. The `ld_library` rule is modified to take a new substitution dictionary as input which is subject to location expansion. This allows for example to do in the linker script: ``` INCLUDE @@myfile@@ ``` and then in the BUILD file: ``` ld_library( ..., substitutions = { "@@myfile@@": "$(location //path/to/my/file)", }, ) ``` Signed-off-by: Amaury Pouly <[email protected]>
Signed-off-by: Amaury Pouly <[email protected]>
Signed-off-by: Amaury Pouly <[email protected]>
Signed-off-by: Amaury Pouly <[email protected]>
31e79ff
to
6a3a2d6
Compare
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.
This seems fine, but I'll mention that the convention is to use the C preprocessor for this sort of thing. From a support perspective, bazel's APIs are more likely to change in an incompatible way than the C preprocessor, though the risk likely isn't high for this particular activity.
So for a cpp setup, required variables / definitions / macros would go in a required platform-specific header file, the includes paths specified on the command line would handle selecting the correct header, and you'd process it with the C preprocessor to generate the real / final linker script.
That said, for this simple substitution, you get basically the same thing with even the linker script language's own include command. It's not clear the templates in bazel do more than add another DSL to the list of things to know to work with the project (in addition to the required strings to substitute). /shrug
The critical part in this PR is more the abstraction of the path, which was hard-coded as earlgrey. But top-specific linker search paths, directories dedicated to specific targets, and INCLUDE directives would get the job done too (in the ordinary way embedded projects typically do it).
This makes sense, although this is now a bigger project ;) I have created #25908 to investigate this alternative, let's discuss there the details. |
Based on the feedback, I am closing in favor of #25908 |
Linker files are not preprocessed, which makes it hard to support several tops. In particular, including different files based on the top, or using a different region is very difficult. We currently have a semi-hack where we automatically include the directory of any
include
-ed file but it still requires that files have the same name which is not always the case.The
ld_library
rule is modified to take a new substitution dictionary as input which is subject to location expansion. This allows for example to do in the linker script:and then in the BUILD file:
The rest of the commits add some substitutions for the ottf and test_rom, plus a final commit specifically for darjeeling.
Review commit by commit, skip the first which is a squashed version of #25580