-
Notifications
You must be signed in to change notification settings - Fork 28
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
Include macro for building sysimgs #85
Conversation
Forgot that |
Second commit runs macros inside Third commit fixes the 1.0 issue. |
Mostly this needs a test, otherwise looks good. |
Bump. We should get this tagged and released. |
Won't this code get exercised by the existing tests because of the rewrite part? Any idea of how to tests the part that helps system image building? |
Maybe if it works, let's get it merged? |
@timholy Could you provide a hint to the kind of testing that would be useful here. If any. I can try to write such tests but I haven't done any work here before so I'd need some directions. |
I'm not exactly sure what the use-case really is here, but looking again it seems the existing tests already cover this. Sorry for the confusion. This will break Revise, but it should be fixable. |
Currently, things like https://github.com/FluxML/Zygote.jl/blob/ed366f32c0f520567526040d9f8acaf0d83613c3/src/Zygote.jl#L42-L43 aren't compatible with creating system images since the included file might not be available when using the system image. This PR is an attempt to make such usage compatible with system image building. |
I see. And one cannot just use |
|
Sounds good. I guess I was wondering if we could keep it separate from the source code proper. If the file is quite long then this is a big string. But I guess this isn't a huge deal, and if people are worried about that then they should just make it |
@timholy I think you are the only one here that can merge the PR and make the release. |
That said, if there's a way to do this conditionally on building a sysimg, Revise will thank you. (Currently, Is there a way to detect that you're buidling a sysimg and not just ordinary precompiling? For example, could Requires define |
Oh, that's crazy. I just added @KristofferC and @DilumAluthge. Any others I should invite? |
I have the permissions to merge. |
OK, but let's see if anyone is willing to tackle #85 (comment). |
How about we fall back to the serialized string in case the file doesn't exist anymore but otherwise use the current mechanism? |
@KristofferC Would you be able to add a commit with that proposal? |
Yeah, I'll try. |
I went ahead and implemented the approach suggested by @KristofferC in #85 (comment). See #92 I also added a test to cover the new behavior. |
This reverts to using the normal include() mechanism in @-require, and only falling back to the macro expansion-time include_string if the file doesn't exist at runtime.
Superseded by #92 |
Hmm, this still seems to have broken Revise EDIT: not just Windows, it turns out I was still using Requires 1.0.3 locally. See https://travis-ci.org/github/timholy/Revise.jl/builds/732701350. I don't have time to dig into this right now myself, and won't for several days, so I'd appreciate help. |
Filed as a separate bug report, see #94. |
This reverts to using the normal include() mechanism in @-require, and only falling back to the macro expansion-time include_string if the file doesn't exist at runtime. Co-authored-by: Chris Foster <[email protected]>
This PR adds an
@include
macro which behaves likeinclude
, but is more compatible with compiling a sysimg.Separately, it also adds a hook to replace
include
statements in@require
block with@include
. This risks being a bit magical but shouldn't affect normal usage at all, only sysimg usage. The main edge case is recursiveinclude
during sysimg compilation (e.g. file included by Requires has anotherinclude
in it). Since this is pretty uncommon, it should make most Requires usage just work with sysimg building.