Skip to content

Commit

Permalink
buildsys: make Julia integration more robust
Browse files Browse the repository at this point in the history
Now configure only checks for a julia binary; then we use julia-config.jl to
determine all relevant paths, and do it all from inside Makefile.rules. The
downside of this is that if we find a broken Julia, this won't work, but
configure won't tell us. The upside is that we get all the correct compiler
and linker flags. In particular, we don't have to hardcode `#define
JULIA_ENABLE_THREADING` anymore.
  • Loading branch information
fingolfin committed Oct 9, 2018
1 parent 41517f5 commit e6b5fc1
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 33 deletions.
1 change: 1 addition & 0 deletions GNUmakefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ READLINE_CPPFLAGS = @READLINE_CPPFLAGS@
READLINE_LDFLAGS = @READLINE_LDFLAGS@
READLINE_LIBS = @READLINE_LIBS@

JULIA = @JULIA@
JULIA_CPPFLAGS = @JULIA_CPPFLAGS@
JULIA_LDFLAGS = @JULIA_LDFLAGS@
JULIA_LIBS = @JULIA_LIBS@
Expand Down
2 changes: 2 additions & 0 deletions Makefile.rules
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,8 @@ sysinfo.gap: config.status $(srcdir)/Makefile.rules cnf/GAP-CFLAGS cnf/GAP-CPPFL
@echo "GAP_LIBS=\"$(GAP_LIBS)\"" >> $@
@echo "" >> $@
@echo "GAP_OBJS=\"$(OBJS)\"" >> $@
@echo "" >> $@
@echo "JULIA=\"$(JULIA)\"" >> $@

# regenerate bin/gap.sh if necessary
all: bin/gap.sh
Expand Down
65 changes: 34 additions & 31 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -478,44 +478,47 @@ AC_SUBST([READLINE_LIBS])
dnl Find julia
AC_ARG_WITH([julia],
[AS_HELP_STRING([--with-julia@<:@=PREFIX@:>@],
[specify a prefix where julia can be found])])
[specify a prefix where julia can be found])],
[],[with_julia=no]
)

AS_IF([test "x$with_julia" != xno],[
JULIA_LIBS="-ljulia"
AS_CASE([x"$with_julia"],
[xyes|x],[
JULIA_CPPFLAGS=
JULIA_LDFLAGS=
],
[*],[
JULIA_CPPFLAGS="-I$with_julia/include/julia"
JULIA_LDFLAGS="-L$with_julia/lib -Wl,-rpath,$with_julia/lib"
JULIA_LIBS="-ljulia"
]
)
AX_CHECK_LIBRARY([JULIA], [julia.h], [julia], [jl_gc_alloc], [], [], [])
# TODO: also check for gcext.h, so that we can be sure the user is pointing
# at a modified version of Julia.
AS_IF([test $ax_cv_have_JULIA = yes],[
AC_DEFINE([HAVE_LIBJULIA], [1], [Define if you have libjulia])
],[
AS_CASE([x"$with_julia"],
[x], [JULIA_CPPFLAGS= JULIA_LDFLAGS= JULIA_LIBS=],
[*], [AC_MSG_FAILURE([--with-julia was given, but test for julia failed])]
)
])
AC_PATH_PROG([JULIA], [julia], [], [${with_julia}/bin ${PATH}])
AS_IF([test "x$JULIA" = x],[ AC_MSG_ERROR([no julia executable found]) ])
JL_SHARE=$($JULIA -e 'print(joinpath(Sys.BINDIR, Base.DATAROOTDIR, "julia"))')
AS_IF([test -f "${JL_SHARE}/julia-config.jl"], [], [AC_MSG_ERROR([no julia-config.jl found])])
AC_MSG_CHECKING([for JULIA_CPPFLAGS])
JULIA_CPPFLAGS=$(${JULIA} ${JL_SHARE}/julia-config.jl --cflags 2>/dev/null)
AS_IF([ test $? != 0 ], [AC_MSG_ERROR([failed to obtain JULIA_CPPFLAGS from julia-config.jl])])
JULIA_CPPFLAGS=${JULIA_CPPFLAGS/-std=gnu99/} # need to remove -std=gnu99 for our C++ code
# remove apostrophes, they mess up quoting when used in shell code(although
# they are fine inside of Makefiles); this could cause problems if any
# paths involve spaces, but then we likely will haves problem in other
# places; in any case, if anybody ever cares about this, we can work on
# finding a better solution.
JULIA_CPPFLAGS=${JULIA_CPPFLAGS//\'/}
AC_MSG_RESULT([${JULIA_CPPFLAGS}])
AC_MSG_CHECKING([for JULIA_LDFLAGS])
JULIA_LDFLAGS=$(${JULIA} ${JL_SHARE}/julia-config.jl --ldflags)
AS_IF([ test $? != 0 ], [AC_MSG_ERROR([failed to obtain JULIA_LDFLAGS from julia-config.jl])])
JULIA_LDFLAGS=${JULIA_LDFLAGS//\'/}
AC_MSG_RESULT([${JULIA_LDFLAGS}])
AC_MSG_CHECKING([for JULIA_LIBS])
JULIA_LIBS=$(${JULIA} ${JL_SHARE}/julia-config.jl --ldlibs)
AS_IF([ test $? != 0 ], [AC_MSG_ERROR([failed to obtain JULIA_LIBS from julia-config.jl])])
JULIA_LIBS=${JULIA_LIBS//\'/}
AC_MSG_RESULT([${JULIA_LIBS}])
])

dnl TODO: check if $with_gc = julia; if so, error out if julia is not found


AC_SUBST([JULIA])
AC_SUBST([JULIA_CPPFLAGS])
AC_SUBST([JULIA_LDFLAGS])
AC_SUBST([JULIA_LIBS])

dnl TODO: check if $with_gc = julia; if so, error out if julia is not found

dnl Find ward (if HPC-GAP mode is enabled)
AC_ARG_WITH([ward],
Expand Down
2 changes: 0 additions & 2 deletions src/julia_gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
** and gasman.c for two other garbage collector implementations.
**/

#define JULIA_ENABLE_THREADING

#include "code.h"
#include "funcs.h"
#include "gapstate.h"
Expand Down

0 comments on commit e6b5fc1

Please sign in to comment.