-
-
Notifications
You must be signed in to change notification settings - Fork 5.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
Fix embedding example, simplify Makefile, and test it #20535
Conversation
examples/Makefile
Outdated
@@ -1,41 +1,25 @@ | |||
JULIAHOME = $(abspath ..) | |||
include $(JULIAHOME)/Make.inc | |||
JULIA = $(abspath ../usr/bin/julia) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this isn't right for an out-of-tree build
examples/Makefile
Outdated
JULIAHOME = $(abspath ..) | ||
include $(JULIAHOME)/Make.inc | ||
JULIA = $(abspath ../usr/bin/julia) | ||
JL_SHARE = $(shell $(JULIA) -e 'print(joinpath(JULIA_HOME,Base.DATAROOTDIR,"julia"))') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
may require spawn
examples/Makefile
Outdated
ifneq ($(UNTRUSTED_SYSTEM_LIBM),0) | ||
JLDFLAGS += $(WHOLE_ARCHIVE) $(build_libdir)/libopenlibm.a $(NO_WHOLE_ARCHIVE) | ||
endif | ||
ifeq ($(OS),Windows_NT) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not correct for cross-compiling
src/julia.h
Outdated
@@ -1313,6 +1313,7 @@ JL_DLLEXPORT void julia_init(JL_IMAGE_SEARCH rel); | |||
JL_DLLEXPORT void jl_init(const char *julia_home_dir); | |||
JL_DLLEXPORT void jl_init_with_image(const char *julia_home_dir, | |||
const char *image_relative_path); | |||
JL_DLLEXPORT const char* jl_get_default_sysimg_path(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if exported, needs JL_DLLEXPORT on both prototype and implementation
a1be72d
to
0638ec2
Compare
Updated, thanks. I'm going for non-reliance on I'll note that this example isn't built at all right now with out-of-tree. |
Win64 and OSX test failures seem unrelated. |
0638ec2
to
9378555
Compare
examples/Makefile
Outdated
|
||
ifeq ($(USE_SYSTEM_LIBM),0) | ||
ifneq ($(UNTRUSTED_SYSTEM_LIBM),0) | ||
JLDFLAGS += $(WHOLE_ARCHIVE) $(build_libdir)/libopenlibm.a $(NO_WHOLE_ARCHIVE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does julia-config handle this and the llvm-config output?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
libm yes, llvm-config no. Doesn't libjulia link llvm already?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes but presumably the llvm-config --ldflags call was needed for something
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was added in 072a861 when the file was created. My guess is copy-paste or prior/local build issue. If it breaks the example we can put it back.
test/examples.jl
Outdated
|
||
# test that the embedding example runs without error | ||
let | ||
lines = readlines(pipeline(`$(joinpath(JULIA_HOME,Base.DATAROOTDIR,"doc","julia","examples","embedding","embedding"))`, stderr=DevNull)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wrap long line
examples/embedding/Makefile
Outdated
$(CC) $^ -o $@ $(CFLAGS) $(DEBUGFLAGS) | ||
|
||
clean: | ||
rm -f *.o *.do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doesn't look like this will create any object files any more
we shouldn't install binaries in the same place as documentation and source code. installing and redistributing the compiled embedding results isn't the most useful test of this, see my comments on #18688 |
9378555
to
128f941
Compare
Ok:
|
examples/embedding/Makefile
Outdated
# hooks for julia build system | ||
ifdef BUILDROOT | ||
SRCDIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))/ | ||
BINDIR := $(abspath $(BUILDROOT)/usr/libexec)/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
build_libexecdir
dcfd49a
to
69ea5ea
Compare
examples/embedding/Makefile
Outdated
$(error "Please set JULIA to the path of the target julia binary!") | ||
endif | ||
ifndef BIN | ||
$(error "Please set BIN to the path of the build directory!") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could maybe use a bit more clarification what is meant by this
2ebb8db
to
f4312aa
Compare
examples/embedding/Makefile
Outdated
$(BIN)/embedding$(EXE): embedding.c | ||
$(CC) $^ -o $@ $(CFLAGS) | ||
|
||
$(BINDIR)/embedding-debug$(EXE): embedding.c |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this also be BIN ?
debug: $(BIN)/embedding-debug$(EXE) | ||
|
||
$(BIN)/embedding$(EXE): embedding.c | ||
$(CC) $^ -o $@ $(CFLAGS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might want to also explicitly error if CC isn't set, or default to cc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make
already does that
- get rid of makefile cruft - use julia-config for flags, as documented in manual - build into `libexec` also move to subdir for clarity.
@@ -70,9 +70,9 @@ function cflags() | |||
arg2 = replace(includeDir(),"\\","\\\\") | |||
threading_def = threadingOn() ? "-DJULIA_ENABLE_THREADING=1 " : "" | |||
if is_unix() | |||
return """$(threading_def)-fPIC -DJULIA_INIT_DIR=\\"$arg1\\" -I$arg2""" | |||
return """-std=gnu99 $(threading_def)-fPIC -DJULIA_INIT_DIR=\\"$arg1\\" -I$arg2""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does the runtime need this, or the code in the embedding example?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the runtime.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are we using gnu extensions in our headers, or which compiler versions don't default to c99 mode?
@@ -14,7 +14,7 @@ double my_c_sqrt(double x) | |||
|
|||
int main() | |||
{ | |||
jl_init(NULL); | |||
jl_init(JULIA_INIT_DIR); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this still work with NULL
as the argument?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, even better, it looks like jl_init
takes no arguments now?
julia_init(JL_IMAGE_JULIA_HOME); | ||
jl_exception_clear(); | ||
} | ||
|
||
JL_DLLEXPORT void jl_init(const char *julia_home_dir) | ||
JL_DLLEXPORT void jl_init() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be jl_init(void)
.
JL_DLLEXPORT int jl_is_initialized(void); | ||
JL_DLLEXPORT void jl_atexit_hook(int status); | ||
JL_DLLEXPORT void JL_NORETURN jl_exit(int status); | ||
JL_DLLEXPORT const char* jl_pathname_for_handle(void *handle); | ||
JL_DLLEXPORT const char* jl_get_default_sysimg_path(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is duplicated and needs (void)
.
Bump. |
Moved to #21299. |
(related: #18421)