public inbox for jit@gcc.gnu.org
 help / color / mirror / Atom feed
From: David Malcolm <dmalcolm@redhat.com>
To: Dibyendu Majumdar <mobile@majumdar.org.uk>
Cc: jit@gcc.gnu.org
Subject: Re: libgccjit 5.2 on Mac OSX Yosemite
Date: Thu, 01 Jan 2015 00:00:00 -0000	[thread overview]
Message-ID: <1439241838.21752.79.camel@surprise> (raw)
In-Reply-To: <CACXZuxdE9RrAqOVYNCmVqwX85jYEYiG+-Oj8Z3achAonqZGsuA@mail.gmail.com>

On Mon, 2015-08-10 at 21:36 +0100, Dibyendu Majumdar wrote:
> Hi
> 
> I tried building gcc 5.2 on Mac OSX but could not get the linking to
> work. Then fortunately found that homebrew has a formula for deploy
> gcc 5.2 with jit enabled.


Aha.  Thanks.  This would seem to be:
 https://github.com/Homebrew/homebrew/blob/master/Library/Formula/gcc.rb

which I see slightly patches
  gcc/jit/Make-lang.in
to avoid an assumption that we're building using the GNU linker.



> All installed and then built Ravi successfully. But when I try to run
> Ravi any attempt to invoke the JIT fails with:
> 
> Lua 5.3.1  Copyright (C) 1994-2015 Lua.org, PUC-Rio
> 
> > function x() return end
> 
> > ravi.compile(x)
> 
> Undefined symbols for architecture x86_64:
> 
>   "_luaD_poscall", referenced from:
> 
>       _ravif1 in cczhNq92.o
> 
>   "_luaF_close", referenced from:
> 
>       _ravif1 in cczhNq92.o
> 
> ld: symbol(s) not found for architecture x86_64
> 
> collect2: error: ld returned 1 exit status
> 
> libgccjit.so: error: error invoking gcc driver: exit_status: 256 err: 0
> 
> libgccjit.so: error: whilst attempting to run a driver named:
> x86_64-apple-darwin14.4.0-gcc-5.2.0
> 
> libgccjit.so: error: PATH was:
> /Users/username/github/ravi/build:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/git/bin:/Library/TeX/texbin
> 
> aborting due to JIT error: error invoking gcc driver: exit_status: 256 err: 0
> 
> Abort trap: 6
> 
> Any clues?
> 
> I had set PATH and LD_LIBRARY_PATH.

Presumably "luaD_poscall" and "luaF_close" are symbols that you're
exporting from ravi for use by the JIT-generated code, via:
https://github.com/dibyendumajumdar/ravi/blob/master/src/ravi_gcctypes.c#L802

  t->luaD_poscallT = gcc_jit_context_new_function(
      ravi->context, NULL, GCC_JIT_FUNCTION_IMPORTED, t->C_intT,
"luaD_poscall",
      3, params, 0);

I'm not quite sure exactly where the leading underscore came from.

This appears to be a linker error from the static link that creates the
jit-generated .so file.  If I'm reading things right, it's complaining
that the code is using luaD_poscall, but it doesn't have a definition
for it.

My guess is that "ld" on OS X has slightly different behavior from the
GNU "ld" I've been developing against, and that it defaults to a
stricter linkage model where it wants to see those symbols upfront, when
we want to defer them until the later dynamic link phase (when we dlopen
the generated .so file).  This is a guess though.

What does "ld --version" print?

It may be easiest to try to work from a minimal reproducer for this.
To that end, what happens if you try building and running
  gcc/testsuite/jit.dg/test-calling-external-function.c
from the jit testsuite, using the homebrew build?


Thanks
Dave



  reply	other threads:[~2015-08-10 21:24 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-01  0:00 Dibyendu Majumdar
2015-01-01  0:00 ` David Malcolm [this message]
2015-01-01  0:00   ` David Malcolm
     [not found]     ` <CACXZuxcMbdLjzv01WyNReKCub=jZW4Qow1iZKz3juYfo-vEk=w@mail.gmail.com>
2015-01-01  0:00       ` David Malcolm
2015-01-01  0:00         ` Dibyendu Majumdar
2015-01-01  0:00 Dibyendu Majumdar
2015-01-01  0:00 ` Dibyendu Majumdar
2015-01-01  0:00   ` David Malcolm
2015-01-01  0:00     ` Dibyendu Majumdar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1439241838.21752.79.camel@surprise \
    --to=dmalcolm@redhat.com \
    --cc=jit@gcc.gnu.org \
    --cc=mobile@majumdar.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).