-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Internal IR for compiler args #14748
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
Draft
dcbaker
wants to merge
5
commits into
mesonbuild:master
Choose a base branch
from
dcbaker:submit/compile-args-abstraction
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
347f310
WIP: arguments: Add a new module for compiler argument abstraction
dcbaker d8966f8
WIP: compilers: Add methods to convert between abstract and concrete …
dcbaker 9073f15
WIP: compilers: implement arguments methods for GNU-like compilers
dcbaker e4a09c7
WIP: build: convert Build layer to use Arguments
dcbaker bdccf01
WIP: backend/ninja: use Arguments
dcbaker File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# Copyright © 2025 Intel Corporation | ||
|
||
"""An abstract IR for compile arguments. | ||
|
||
This provides us with a way to pass arguments around in a non-compiler specific | ||
way internally, and lower them into a non-abstract format when writing them in | ||
the backend. | ||
""" | ||
|
||
from __future__ import annotations | ||
import dataclasses | ||
import typing as T | ||
|
||
if T.TYPE_CHECKING: | ||
from typing_extensions import TypeAlias | ||
|
||
# A Union of all Argument types | ||
Argument: TypeAlias = T.Union[ | ||
'Opaque', 'Warning', 'Error', 'Define', 'Undefine', 'LinkerSearch', 'LinkLibrary' | ||
] | ||
|
||
|
||
@dataclasses.dataclass | ||
class Opaque: | ||
|
||
"""An opaque argument. | ||
|
||
This is an argument of unknown type, and Meson will do nothing but proxy it | ||
through, except to apply a prefix to the value if it thinks it's necessary. | ||
|
||
:param value: | ||
""" | ||
|
||
value: str | ||
|
||
|
||
@dataclasses.dataclass | ||
class Warning: | ||
|
||
"""A compiler warning. | ||
|
||
:param target: The warning to enable or disable. This will be stored as | ||
given (ie, we don't try to convert between compilers). | ||
:param enable: If true then enable the warning, otherwise suppress it. | ||
""" | ||
|
||
target: str | ||
enable: bool | ||
|
||
|
||
@dataclasses.dataclass | ||
class Error: | ||
|
||
"""A compiler error. | ||
|
||
:param target: The warning to enable or disable. This will be stored as | ||
given (ie, we don't try to convert between compilers). | ||
:param enable: If true then enable the warning, otherwise suppress it. | ||
""" | ||
|
||
target: str | ||
|
||
|
||
@dataclasses.dataclass | ||
class Define: | ||
|
||
"""A pre-processor define. | ||
|
||
:param target: The value to define. | ||
:param value: An optional value to set the define to. If undefined them the | ||
value will be defined with no value. | ||
""" | ||
|
||
target: str | ||
value: T.Optional[str] | ||
|
||
|
||
@dataclasses.dataclass | ||
class Undefine: | ||
|
||
"""A pre-processor undefine. | ||
|
||
:param target: The value to define. | ||
""" | ||
|
||
target: str | ||
|
||
|
||
@dataclasses.dataclass | ||
class LinkerSearch: | ||
|
||
"""A location for the linker to search for libraries. | ||
|
||
:param path: The path to search. | ||
""" | ||
|
||
path: str | ||
|
||
|
||
@dataclasses.dataclass | ||
class LinkLibrary: | ||
|
||
"""A library to link with. | ||
|
||
:param name: The name of the library to link. | ||
""" | ||
|
||
name: str | ||
|
||
|
||
# TODO: rpath | ||
# TODO: rust cfgs | ||
# TODO: other flags we might handle differently and want to convert like lto, sanitizers, etc |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 think an
enable
member went missing here.