Skip to content

Commit

Permalink
Bake rem2pi from openspecfun into the system image
Browse files Browse the repository at this point in the history
  • Loading branch information
ararslan committed Feb 3, 2017
1 parent 5c33186 commit c3ac805
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 11 deletions.
3 changes: 1 addition & 2 deletions base/math.jl
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ log(b::Number, x::Number) = log(promote(b,x)...)
# type specific math functions

const libm = Base.libm_name
const openspecfun = "libopenspecfun"

# functions with no domain error
"""
Expand Down Expand Up @@ -701,7 +700,7 @@ function ieee754_rem_pio2(x::Float64)
# https://github.com/JuliaLang/openspecfun/blob/master/rem_pio2/e_rem_pio2.c

y = [0.0,0.0]
n = ccall((:__ieee754_rem_pio2, openspecfun), Cint, (Float64,Ptr{Float64}), x, y)
n = ccall(:__ieee754_rem_pio2, Cint, (Float64,Ptr{Float64}), x, y)
return (n,y)
end

Expand Down
27 changes: 18 additions & 9 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ FLAGS += -DLLVM_SHLIB
endif # USE_LLVM_SHLIB == 1

COMMON_LIBS := -L$(build_shlibdir) -L$(build_libdir) $(LIBUV) $(LIBUTF8PROC) $(NO_WHOLE_ARCHIVE) $(LLVMLINK) $(OSLIBS)
DEBUG_LIBS := $(WHOLE_ARCHIVE) $(BUILDDIR)/flisp/libflisp-debug.a $(WHOLE_ARCHIVE) $(BUILDDIR)/support/libsupport-debug.a $(COMMON_LIBS)
RELEASE_LIBS := $(WHOLE_ARCHIVE) $(BUILDDIR)/flisp/libflisp.a $(WHOLE_ARCHIVE) $(BUILDDIR)/support/libsupport.a $(COMMON_LIBS)
DEBUG_LIBS := $(WHOLE_ARCHIVE) $(BUILDDIR)/flisp/libflisp-debug.a $(WHOLE_ARCHIVE) $(BUILDDIR)/support/libsupport-debug.a $(WHOLE_ARCHIVE) $(BUILDDIR)/specfun/libspecfun-debug.a $(COMMON_LIBS)
RELEASE_LIBS := $(WHOLE_ARCHIVE) $(BUILDDIR)/flisp/libflisp.a $(WHOLE_ARCHIVE) $(BUILDDIR)/support/libsupport.a $(WHOLE_ARCHIVE) $(BUILDDIR)/specfun/libspecfun.a $(COMMON_LIBS)

OBJS := $(SRCS:%=$(BUILDDIR)/%.o)
DOBJS := $(SRCS:%=$(BUILDDIR)/%.dbg.obj)
Expand Down Expand Up @@ -203,12 +203,18 @@ $(BUILDDIR)/support/libsupport.a: $(SRCDIR)/support/*.h $(SRCDIR)/support/*.c
$(BUILDDIR)/support/libsupport-debug.a: $(SRCDIR)/support/*.h $(SRCDIR)/support/*.c
$(MAKE) -C $(SRCDIR)/support debug BUILDDIR='$(abspath $(BUILDDIR)/support)'

$(BUILDDIR)/specfun/libspecfun.a: $(SRCDIR)/specfun/*.h $(SRCDIR)/specfun/*.c $(BUILDDIR)/support/libsupport.a
$(MAKE) -C $(SRCDIR)/specfun BUILDDIR='$(abspath $(BUILDDIR)/specfun)'

$(BUILDDIR)/specfun/libspecfun-debug.a: $(SRCDIR)/specfun/*.h $(SRCDIR)/specfun/*.c $(BUILDDIR)/support/libsupport-debug.a
$(MAKE) -C $(SRCDIR)/specfun debug BUILDDIR='$(abspath $(BUILDDIR)/specfun)'

$(FLISP_EXECUTABLE_release): $(BUILDDIR)/flisp/libflisp.a
$(BUILDDIR)/flisp/libflisp.a: $(addprefix $(SRCDIR)/,flisp/*.h flisp/*.c) $(BUILDDIR)/support/libsupport.a
$(BUILDDIR)/flisp/libflisp.a: $(addprefix $(SRCDIR)/,flisp/*.h flisp/*.c) $(BUILDDIR)/specfun/libspecfun.a
$(MAKE) -C $(SRCDIR)/flisp BUILDDIR='$(abspath $(BUILDDIR)/flisp)'

$(FLISP_EXECUTABLE_debug): $(BUILDDIR)/flisp/libflisp-debug.a
$(BUILDDIR)/flisp/libflisp-debug.a: $(addprefix $(SRCDIR)/,flisp/*.h flisp/*.c) $(BUILDDIR)/support/libsupport-debug.a
$(BUILDDIR)/flisp/libflisp-debug.a: $(addprefix $(SRCDIR)/,flisp/*.h flisp/*.c) $(BUILDDIR)/specfun/libspecfun-debug.a
$(MAKE) -C $(SRCDIR)/flisp debug BUILDDIR='$(abspath $(BUILDDIR)/flisp)'

$(BUILDDIR)/julia_version.h: $(JULIAHOME)/VERSION
Expand Down Expand Up @@ -255,7 +261,7 @@ else
SONAME_DEBUG :=
endif

$(build_shlibdir)/libjulia-debug.$(JL_MAJOR_MINOR_SHLIB_EXT): $(SRCDIR)/julia.expmap $(DOBJS) $(BUILDDIR)/flisp/libflisp-debug.a $(BUILDDIR)/support/libsupport-debug.a $(LIBUV)
$(build_shlibdir)/libjulia-debug.$(JL_MAJOR_MINOR_SHLIB_EXT): $(SRCDIR)/julia.expmap $(DOBJS) $(BUILDDIR)/flisp/libflisp-debug.a $(BUILDDIR)/support/libsupport-debug.a $(BUILDDIR)/specfun/libspecfun-debug.a $(LIBUV)
@$(call PRINT_LINK, $(CXXLD) $(CXXFLAGS) $(CXXLDFLAGS) $(DEBUGFLAGS) $(DOBJS) $(RPATH_LIB) -o $@ $(LDFLAGS) $(JLIBLDFLAGS) $(DEBUG_LIBS) $(SONAME_DEBUG))
$(INSTALL_NAME_CMD)libjulia-debug.$(SHLIB_EXT) $@
ifneq ($(OS), WINNT)
Expand All @@ -264,13 +270,13 @@ ifneq ($(OS), WINNT)
endif
$(DSYMUTIL) $@

$(BUILDDIR)/libjulia-debug.a: $(SRCDIR)/julia.expmap $(DOBJS) $(BUILDDIR)/flisp/libflisp-debug.a $(BUILDDIR)/support/libsupport-debug.a
$(BUILDDIR)/libjulia-debug.a: $(SRCDIR)/julia.expmap $(DOBJS) $(BUILDDIR)/flisp/libflisp-debug.a $(BUILDDIR)/support/libsupport-debug.a $(BUILDDIR)/specfun/libspecfun-debug.a
rm -f $@
@$(call PRINT_LINK, ar -rcs $@ $(DOBJS))

libjulia-debug: $(build_shlibdir)/libjulia-debug.$(JL_MAJOR_MINOR_SHLIB_EXT) $(PUBLIC_HEADER_TARGETS)

$(build_shlibdir)/libjulia.$(JL_MAJOR_MINOR_SHLIB_EXT): $(SRCDIR)/julia.expmap $(OBJS) $(BUILDDIR)/flisp/libflisp.a $(BUILDDIR)/support/libsupport.a $(LIBUV)
$(build_shlibdir)/libjulia.$(JL_MAJOR_MINOR_SHLIB_EXT): $(SRCDIR)/julia.expmap $(OBJS) $(BUILDDIR)/flisp/libflisp.a $(BUILDDIR)/support/libsupport.a $(BUILDDIR)/specfun/libspecfun.a $(LIBUV)
@$(call PRINT_LINK, $(CXXLD) $(CXXFLAGS) $(CXXLDFLAGS) $(SHIPFLAGS) $(OBJS) $(RPATH_LIB) -o $@ $(LDFLAGS) $(JLIBLDFLAGS) $(RELEASE_LIBS) $(SONAME))
$(INSTALL_NAME_CMD)libjulia.$(SHLIB_EXT) $@
ifneq ($(OS), WINNT)
Expand All @@ -279,7 +285,7 @@ ifneq ($(OS), WINNT)
endif
$(DSYMUTIL) $@

$(BUILDDIR)/libjulia.a: julia.expmap $(OBJS) $(BUILDDIR)/flisp/libflisp.a $(BUILDDIR)/support/libsupport.a
$(BUILDDIR)/libjulia.a: julia.expmap $(OBJS) $(BUILDDIR)/flisp/libflisp.a $(BUILDDIR)/support/libsupport.a $(BUILDDIR)/specfun/libspecfun.a
rm -f $@
@$(call PRINT_LINK, ar -rcs $@ $(OBJS))
libjulia-release: $(build_shlibdir)/libjulia.$(JL_MAJOR_MINOR_SHLIB_EXT) $(PUBLIC_HEADER_TARGETS)
Expand All @@ -296,7 +302,10 @@ clean-flisp:
clean-support:
-$(MAKE) -C $(SRCDIR)/support clean BUILDDIR='$(abspath $(BUILDDIR)/support)'

clean-specfun:
-$(MAKE) -C $(SRCDIR)/specfun clean BUILDDIR='$(abspath $(BUILDDIR)/specfun)'


cleanall: clean clean-flisp clean-support
cleanall: clean clean-flisp clean-support clean-specfun

.PHONY: default all debug release clean cleanall clean-* libccalltest julia_flisp.boot.inc.phony
50 changes: 50 additions & 0 deletions src/specfun/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
JULIAHOME := $(abspath ../..)
BUILDDIR := .
include $(JULIAHOME)/Make.inc

override CFLAGS_add =
override CPPFLAGS_add =

ifeq ($(USECLANG),1)
override CFLAGS_add += -fno-builtin
endif

ifeq ($(USEGCC),1)
override CFLAGS_add += -fno-gnu89-inline -std=c99
endif

ifeq ($(USE_SYSTEM_LIBM),0)
override CPPFLAGS_add += -DUSE_OPENLIBM -I$(build_includedir) -I$(build_includedir)/openlibm
endif

override CFLAGS += $(JCFLAGS) -O3 -std=c99
ifeq ($(USEICC),1)
override CFLAGS += -fp-model precise
endif

ifeq ($(OS),WINNT)
override CFLAGS_add += -nodefaultlibs
else
override CFLAGS_add += -fPIC
endif

SRCS := e_rem_pio2.c e_rem_pio2f.c k_rem_pio2.c
OBJS := $(addprefix $(BUILDDIR)/,$(patsubst %.c,%.o,$(SRCS)))

default: $(JULIA_BUILD_MODE)

all: release debug
release: $(BUILDDIR)/libspecfun.a
debug: $(BUILDDIR)/libspecfun-debug.a

$(BUILDDIR)/%.o: $(BUILDDIR)/%.c
$(CC) $(CPPFLAGS) $(CPPFLAGS_add) $(CFLAGS_add) $(CFLAGS) -c $< -o $@

$(BUILDDIR)/libspecfun.a: $(OBJS)
$(AR) -rcs libspecfun.a $(OBJS)

$(BUILDDIR)/libspecfun-debug.a: $(OBJS)
$(AR) -rcs libspecfun-debug.a $(OBJS)

clean:
cd $(BUILDDIR) && rm $(OBJS) *.a
Binary file added src/specfun/libspecfun.a
Binary file not shown.

0 comments on commit c3ac805

Please sign in to comment.