Skip to content
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

Enable macros to use certain things from the OS module when the target OS is not supported #24639

Merged
merged 4 commits into from
Jan 24, 2025

Conversation

PMunch
Copy link
Contributor

@PMunch PMunch commented Jan 23, 2025

Essentially this PR removes the {.error.} pragmas littered around in the OS module and submodules which prevents them from being imported if the target OS is not supported. This made it impossible to use certain supported features of the OS module in macros from a supported host OS. Instead of the {.error.} pragmas the oscommon module now has a constant supportedSystem which is false in the cases where the {.error.} pragmas where generated. All procedures which can't be run by macros is also not declared when supportedSystem is false.

It would be possible to create dummy versions of the omitted functions with an {.error.} pragma that would trigger upon their use, but this is currently not done.

This properly fixes #19414

@Araq Araq closed this Jan 24, 2025
@Araq Araq reopened this Jan 24, 2025
@Araq Araq merged commit 1f9cac1 into nim-lang:devel Jan 24, 2025
30 checks passed
Copy link
Contributor

Thanks for your hard work on this PR!
The lines below are statistics of the Nim compiler built from 1f9cac1

Hint: mm: orc; opt: speed; options: -d:release
178457 lines; 8.703s; 651.383MiB peakmem

narimiran pushed a commit that referenced this pull request Jan 27, 2025
…t OS is not supported (#24639)

Essentially this PR removes the `{.error.}` pragmas littered around in
the OS module and submodules which prevents them from being imported if
the target OS is not supported. This made it impossible to use certain
supported features of the OS module in macros from a supported host OS.
Instead of the `{.error.}` pragmas the `oscommon` module now has a
constant `supportedSystem` which is false in the cases where the
`{.error.}` pragmas where generated. All procedures which can't be run
by macros is also not declared when `supportedSystem` is false.

It would be possible to create dummy versions of the omitted functions
with an `{.error.}` pragma that would trigger upon their use, but this
is currently not done.

This properly fixes #19414

(cherry picked from commit 1f9cac1)
@ringabout
Copy link
Member

/home/runner/work/nightlies/nightlies/nim/lib/pure/os.nim(262, 27) Error: undeclared identifier: 'readlink'

https://github.com/nim-lang/nightlies/actions/runs/12980447170/job/36197485904

It seems to break nightlies

@PMunch
Copy link
Contributor Author

PMunch commented Jan 27, 2025

Created a new PR to fix this issue: #24652

narimiran pushed a commit that referenced this pull request Jan 27, 2025
This should fix ringabouts comment here:
#24639 (comment)

I wasn't aware that `nintendoswitch` and `posix` would be active at the
same time, so I falsely inverted a check.
narimiran pushed a commit that referenced this pull request Jan 27, 2025
This should fix ringabouts comment here:
#24639 (comment)

I wasn't aware that `nintendoswitch` and `posix` would be active at the
same time, so I falsely inverted a check.

(cherry picked from commit cab3342)
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.

Importing os module for use in macros fails when compiling for platform that doesn't support os
3 participants