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

Fix error in cglobal expressions created by macro with escaped literals #26504

Merged
merged 2 commits into from
Mar 20, 2018

Conversation

jmert
Copy link
Contributor

@jmert jmert commented Mar 18, 2018

In #26297 (#issuecomment-371165725), I made reference to a problem with cglobal expressions created by macros — as PyCall uses — on master. This PR is a [naive] attempt at fixing that issue (which I think ends up being distinct from the original error being reported in #26297).

I don't actually know lisp so this is mostly just guessing, but some time spent with git grep and combinations of @code_lowered and Meta.expand(), I maybe lucked in to a solution.

With this (plus a lot of patience — see #26357) I was actually able to get a PyPlot window to show on master!

Before:

julia> @code_typed cglobal26297()
CodeInfo(:(begin
      Core.SSAValue(0) = (Core.tuple)(:global_var, "libccalltest")::Tuple{Symbol,String}
      Core.SSAValue(1) = (Main.cglobal)(Core.SSAValue(0), Main.Cint)::Ptr{Int32}
      return Core.SSAValue(1)
  end)) => Ptr{Int32}

After:

julia> @code_typed cglobal26297()
CodeInfo(:(begin 
        return (Main.cglobal)((Core.tuple)(:global_var, "libccalltest")::Tuple{Symbol,String}, Main.Cint)::Ptr{Int32}
    end))=>Ptr{Int32}

Verified

This commit was signed with the committer’s verified signature.
renovate-bot Mend Renovate
test/ccall.jl Outdated
# test that the first argument to cglobal is recognized as a tuple literal even through
# macro expansion
macro cglobal26297(sym)
:(cglobal(($(esc(sym)), "libccalltest"), Cint))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no quotes around libccalltest (it's a variable at the top of this file)

@stevengj
Copy link
Member

CI failures seem unrelated...

@JeffBezanson JeffBezanson merged commit d699a7c into JuliaLang:master Mar 20, 2018
@jmert jmert deleted the cglobal_escmacro branch March 20, 2018 14:15
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.

None yet

4 participants