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

Path handling in macro when cross-compiling is broken #19558

Open
PMunch opened this issue Feb 23, 2022 · 2 comments
Open

Path handling in macro when cross-compiling is broken #19558

PMunch opened this issue Feb 23, 2022 · 2 comments

Comments

@PMunch
Copy link
Contributor

PMunch commented Feb 23, 2022

Ran into a big similar to the one I've outlined in #19414. However this time in a slightly different form. When cross-compiling from Linux to Windows I do path handling with / in a macro and then run a program with those paths. Since I had specified --os:windows Nim went ahead and used \ instead of / which meant the paths where no longer valid for the OS which was doing the compiling and the whole thing broke. Nim should really split the compiling OS from the target OS and then checks in macros should be done against the compiling OS and checks in normal procedures should be done against the target OS.

Example

macro test(): string =
  let myFile = someGloballyDefinedFolder / "myfile.txt"
  readFile(myFile)

Compiled with --os:windows on a Linux machine, or vice-versa.

Current Output

"some/globally/defined/foldermyfile.txt", file not found

(Caused by \m not escaping to anything but a normal m)

Expected Output

<contents of "some/globally/defined/folder/myfile.txt">

Possible Solution

  • Fix handling of OS in macros

Additional Information

See: #19414

@SolitudeSF
Copy link
Contributor

and then checks in macros should be done against the compiling OS and checks in normal procedures should be done against the target OS.

that wouldnt solve anything. just because you compose paths at compiletime doesnt mean you access them at compiletime too. there just needs a separate / like operator for compiletime.

@PMunch
Copy link
Contributor Author

PMunch commented Feb 23, 2022

Of course macros would need access to both the compiling OS and the running OS so it could choose which one to use. As it stands now however switching the --os switch means that macros run as the target OS which causes a host of issues, not only with path handling.

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

No branches or pull requests

2 participants