Skip to content

[UR] Support conditional symbols in linker scripts #18629

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

Open
wants to merge 4 commits into
base: sycl
Choose a base branch
from

Conversation

kbenzie
Copy link
Contributor

@kbenzie kbenzie commented May 22, 2025

Combined the following changes enable adding guards around sections in linker script files which do not support conditional inclusion in their syntax. This is done by pre-processing the linker scripts as part of build configuration.

  • Cleanup template helper.py and add typing hints
  • Use dict for functions in loader script templates
    • The get_loader_functions() template helper now returns list[dict] instead of list[str], this enables passing additional information into the loader script templates
  • Add script to strip guarded lines from file
    • In order to pre-process files which don't support conditional inclusion of line blocks, such as linker scripts, we can use this script to remove lines which should not be included unless specified
  • Hook up strip-guarded-lines.py
    • Actually use the strip-guarded-lines.py script when using configure_file() on linker scripts

kbenzie added 4 commits May 23, 2025 09:34
The `get_loader_functions()` template helper now returns `list[dict]`
instead of `list[str]`, this enables passing additional information into
the loader script templates.
In order to pre-process files which don't support conditional inclusion
of line blocks, such as linker scripts, we can use this script to remove
lines which should not be included unless specified.
Actually use the `strip-guarded-lines.py` script when using
`configure_file()` on linker scripts.
@kbenzie kbenzie force-pushed the benie/ur-linker-script-conditional-symbols branch from c81041b to 466c42d Compare May 23, 2025 08:34
@kbenzie kbenzie temporarily deployed to WindowsCILock May 23, 2025 08:34 — with GitHub Actions Inactive
@kbenzie kbenzie temporarily deployed to WindowsCILock May 23, 2025 08:56 — with GitHub Actions Inactive
@kbenzie kbenzie temporarily deployed to WindowsCILock May 23, 2025 08:56 — with GitHub Actions Inactive
try:
return True if re.match(cls.RE_POINTER, name) else False
except:
return bool(re.match(cls.RE_POINTER, name))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would re.match(...) is not None be more idiomatic?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's certainly more typing. Noneness is equivalent to truthiness when uses in if statements. My linter (pyright) doesn't warn about conversion to bool like this, it does warn about using re.match(cls.RE_POINTER, name) == None instead of re.match(cls.RE_POINTER, name) is None.

blocks of lines based on pre and post guard marker lines, a list of guard
names to include in the output, and an input file.

- Pre and post guard marker lines are always removed weather the are guards
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sentence doesn't really make sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about this?

- Pre and post guard marker lines will always be removed even when those guard
  names have not been specified for inclusion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants