-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
refs #16702 make DirSep + friends work with cross-compilation and VM #16916
refs #16702 make DirSep + friends work with cross-compilation and VM #16916
Conversation
Would const AutoSaveDir = "saves" / "automated" # Should be "saves/automated" on POSIX and r"saves\automated" on Windows be compiled to the correct format of the target operating system with this PR? I don't see any tests for this. |
b3fc1a0
to
26ca9ef
Compare
@alaviss see test I added. in particular, this test will pass on a posix host with --os:windows. const dir = "foo" / "bar"
static: doAssert dir == "foo/bar" # this works and is tested in this PR's tests
let dir2 = "foo" / "bar"
doAssert dir2 == "foo\\bar" # I haven't tested this yet, but hopefully it works. That's the most sensible semantics we can implement with current nim semantics IMO, making a clear distinction bw CT(honor host) and RT(honor target) code; if you want ability to use const's that follow target semantics, we'd need something like |
This seems to be a band aid and a breaking change to me. Currently We should define how the CTFE should actually work, and Nim should probably grow a build host/target distinction. I would say that this feature need an RFC, given that it is currently a breaking change. |
I have no idea, probably install mingw? |
I'm heavily against |
@Araq As I wrote in top post, I'm not endorsing this, but this was something worth exploring, I now don't mind if we close this WIP PR. I'm now leaning instead towards timotheecour#598
note: I've actually implemented this in a private branch (with auto-boxing from a non-generic proc declaration to a PNode vm wrapper and using |
well ... until you use |
warning: I'm not necessarily endorsing this approach, but it's one of the options worth considering.
refs #16702
investigates one approach to solve cross-compilation problems involving semantics mismatch between CT and RT. Doesn't fix all issues obviously but this shows at least the most obvious issues can be fixed by simply adding a few key vmops.
this works:
nim c -f --os:windows --skipparentcfg --skipusercfg --compileonly main
foo/bar
/Users/timothee/git_clone/nim/timn/tests/nim/all/t11799.nim
/Users/timothee/git_clone/nim/timn/tests/nim/all
/Users/timothee/git_clone/nim/timn/tests/nim/all
/Users/timothee/git_clone/nim/timn/tests/nim/all/t11799.nim/baz
this gives errors because I don't have a cross compilation toolchain for windows on osx
nim r -f --os:windows --skipparentcfg --skipusercfg main
on osx this shows:
which (ignoring errors because i don't have the windows headers on my system) shows that such an approach might work
@jangko
future work
This could be further simplified by extending vmops to work in more contexts, including const, so that if a const is used in an already static context, it'd use the vmops definition if present.