Skip to content

Commit

Permalink
Remove OpenLibm and leverage native Julia implementations
Browse files Browse the repository at this point in the history
Link to the system libm
  • Loading branch information
ViralBShah committed Feb 18, 2024
1 parent ddd7afb commit 028992f
Show file tree
Hide file tree
Showing 21 changed files with 15 additions and 230 deletions.
39 changes: 5 additions & 34 deletions Make.inc
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ USE_SYSTEM_LLVM:=0
USE_SYSTEM_LIBUNWIND:=0
DISABLE_LIBUNWIND:=0
USE_SYSTEM_PCRE:=0
USE_SYSTEM_LIBM:=0
USE_SYSTEM_OPENLIBM:=0
UNTRUSTED_SYSTEM_LIBM:=0
USE_SYSTEM_DSFMT:=0
USE_SYSTEM_LIBBLASTRAMPOLINE:=0
USE_SYSTEM_BLAS:=0
Expand Down Expand Up @@ -1177,14 +1174,6 @@ LIBLAPACKNAME := liblapack
endif
endif

ifeq ($(USE_SYSTEM_LIBM), 1)
LIBM := -lm
LIBMNAME := libm
else
LIBM := -lopenlibm
LIBMNAME := libopenlibm
endif

ifeq ($(USE_SYSTEM_LIBUV), 1)
LIBUV := $(LOCALBASE)/lib/libuv-julia.a
LIBUV_INC := $(LOCALBASE)/include
Expand Down Expand Up @@ -1268,7 +1257,7 @@ CSL_NEXT_GLIBCXX_VERSION=GLIBCXX_3\.4\.33|GLIBCXX_3\.5\.|GLIBCXX_4\.
# Note: we explicitly _do not_ define `CSL` here, since it requires some more
# advanced techniques to decide whether it should be installed from a BB source
# or not. See `deps/csl.mk` for more detail.
BB_PROJECTS := BLASTRAMPOLINE OPENBLAS LLVM LIBSUITESPARSE OPENLIBM GMP MBEDTLS LIBSSH2 NGHTTP2 MPFR CURL LIBGIT2 PCRE LIBUV LIBUNWIND DSFMT OBJCONV ZLIB P7ZIP LLD LIBTRACYCLIENT
BB_PROJECTS := BLASTRAMPOLINE OPENBLAS LLVM LIBSUITESPARSE GMP MBEDTLS LIBSSH2 NGHTTP2 MPFR CURL LIBGIT2 PCRE LIBUV LIBUNWIND DSFMT OBJCONV ZLIB P7ZIP LLD LIBTRACYCLIENT
define SET_BB_DEFAULT
# First, check to see if BB is disabled on a global setting
ifeq ($$(USE_BINARYBUILDER),0)
Expand Down Expand Up @@ -1398,7 +1387,6 @@ ifeq ($(ARCH),i686)
JLDFLAGS += -Wl,--large-address-aware
endif
JCPPFLAGS += -D_WIN32_WINNT=0x0502
UNTRUSTED_SYSTEM_LIBM := 1
# Use hard links for files on windows, rather than soft links
# https://stackoverflow.com/questions/3648819/how-to-make-a-symbolic-link-with-cygwin-in-windows-7
# Usage: $(WIN_MAKE_HARD_LINK) <source> <target>
Expand Down Expand Up @@ -1473,12 +1461,6 @@ USE_BINARYBUILDER_OPENBLAS := 0
USE_BINARYBUILDER_LIBSUITESPARSE := 0
endif

ifeq ($(USE_SYSTEM_LIBM),1)
# If we're using system libm, disable BB OpenLibm
USE_BINARYBUILDER_OPENLIBM := 0
endif


# Note: we're passing *FLAGS here computed based on your system compiler to
# clang. If that causes you problems, you might want to build and/or run
# specific clang-sa-* files with clang explicitly selected:
Expand Down Expand Up @@ -1634,20 +1616,13 @@ endif
LIBSTDCXX_INSTALL_DEPLIB := $(call dep_lib_path,$(libdir),$(private_shlibdir)/$(LIBSTDCXX_NAME))
endif


# USE_SYSTEM_LIBM and USE_SYSTEM_OPENLIBM causes it to get symlinked into build_private_shlibdir
ifeq ($(USE_SYSTEM_LIBM),1)
LIBM_BUILD_DEPLIB := $(call dep_lib_path,$(build_libdir),$(build_private_shlibdir)/$(LIBMNAME).$(SHLIB_EXT))
else ifeq ($(USE_SYSTEM_OPENLIBM),1)
LIBM_BUILD_DEPLIB := $(call dep_lib_path,$(build_libdir),$(build_private_shlibdir)/$(LIBMNAME).$(SHLIB_EXT))
else
LIBM_BUILD_DEPLIB := $(call dep_lib_path,$(build_libdir),$(build_shlibdir)/$(LIBMNAME).$(SHLIB_EXT))
endif
LIBM_INSTALL_DEPLIB := $(call dep_lib_path,$(libdir),$(private_shlibdir)/$(LIBMNAME).$(SHLIB_EXT))
# Symlink system libm
LIBMNAME := libm
#LIBM_BUILD_DEPLIB := $(call dep_lib_path,$(build_libdir),$(build_shlibdir)/$(LIBMNAME).$(SHLIB_EXT))
#LIBM_INSTALL_DEPLIB := $(call dep_lib_path,$(libdir),$(private_shlibdir)/$(LIBMNAME).$(SHLIB_EXT))

# We list:
# * libgcc_s, because FreeBSD needs to load ours, not the system one.
# * libopenlibm, because Windows has an untrustworthy libm, and we want to use ours more than theirs
# * libstdc++, because while performing `libstdc++` probing we need to
# know the path to the bundled `libstdc++` library.
# * libjulia-internal, which must always come second-to-last.
Expand All @@ -1669,30 +1644,26 @@ endef

LOADER_BUILD_DEP_LIBS = $(call build_deplibs, \
$(LIBGCC_BUILD_DEPLIB) \
$(LIBM_BUILD_DEPLIB) \
@$(LIBSTDCXX_BUILD_DEPLIB) \
@$(LIBJULIAINTERNAL_BUILD_DEPLIB) \
@$(LIBJULIACODEGEN_BUILD_DEPLIB) \
)

LOADER_DEBUG_BUILD_DEP_LIBS = $(call build_deplibs, \
$(LIBGCC_BUILD_DEPLIB) \
$(LIBM_BUILD_DEPLIB) \
@$(LIBSTDCXX_BUILD_DEPLIB) \
@$(LIBJULIAINTERNAL_DEBUG_BUILD_DEPLIB) \
@$(LIBJULIACODEGEN_DEBUG_BUILD_DEPLIB) \
)

LOADER_INSTALL_DEP_LIBS = $(call build_deplibs, \
$(LIBGCC_INSTALL_DEPLIB) \
$(LIBM_INSTALL_DEPLIB) \
@$(LIBSTDCXX_INSTALL_DEPLIB) \
@$(LIBJULIAINTERNAL_INSTALL_DEPLIB) \
@$(LIBJULIACODEGEN_INSTALL_DEPLIB) \
)
LOADER_DEBUG_INSTALL_DEP_LIBS = $(call build_deplibs, \
$(LIBGCC_INSTALL_DEPLIB) \
$(LIBM_INSTALL_DEPLIB) \
@$(LIBSTDCXX_INSTALL_DEPLIB) \
@$(LIBJULIAINTERNAL_DEBUG_INSTALL_DEPLIB) \
@$(LIBJULIACODEGEN_DEBUG_INSTALL_DEPLIB) \
Expand Down
5 changes: 0 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,6 @@ JL_PRIVATE_LIBS-$(USE_SYSTEM_LLVM) += libLLVM $(LLVM_SHARED_LIB_NAME)
endif
JL_PRIVATE_LIBS-$(USE_SYSTEM_LIBUNWIND) += libunwind

ifeq ($(USE_SYSTEM_LIBM),0)
JL_PRIVATE_LIBS-$(USE_SYSTEM_OPENLIBM) += libopenlibm
endif

JL_PRIVATE_LIBS-$(USE_SYSTEM_BLAS) += $(LIBBLASNAME)
ifneq ($(LIBLAPACKNAME),$(LIBBLASNAME))
JL_PRIVATE_LIBS-$(USE_SYSTEM_LAPACK) += $(LIBLAPACKNAME)
Expand Down Expand Up @@ -293,7 +289,6 @@ endif
# We have a single exception; we want 7z.dll to live in private_libexecdir,
# not bindir, so that 7z.exe can find it.
-mv $(DESTDIR)$(bindir)/7z.dll $(DESTDIR)$(private_libexecdir)/
-$(INSTALL_M) $(build_bindir)/libopenlibm.dll.a $(DESTDIR)$(libdir)/
-$(INSTALL_M) $(build_libdir)/libssp.dll.a $(DESTDIR)$(libdir)/
else

Expand Down
1 change: 0 additions & 1 deletion THIRDPARTY.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ and optionally:
Julia's `stdlib` uses the following external libraries, which have their own licenses:

- [DSFMT](https://github.com/MersenneTwister-Lab/dSFMT/blob/master/LICENSE.txt) [BSD-3]
- [OPENLIBM](https://github.com/JuliaMath/openlibm/blob/master/LICENSE.md) [MIT, BSD-2, ISC]
- [GMP](https://gmplib.org/manual/Copying.html#Copying) [LGPL3+ or GPL2+]
- [LIBGIT2](https://github.com/libgit2/libgit2/blob/development/COPYING) [GPL2+ with unlimited linking exception]
- [CURL](https://curl.haxx.se/docs/copyright.html) [MIT/X derivative]
Expand Down
9 changes: 1 addition & 8 deletions base/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ ifeq ($(XC_HOST),)
else
@echo "const MACHINE = \"$(XC_HOST)\"" >> $@
endif
@echo "const libm_name = \"$(LIBMNAME)\"" >> $@
ifeq ($(USE_BLAS64), 1)
@echo "const USE_BLAS64 = true" >> $@
else
Expand Down Expand Up @@ -224,13 +223,7 @@ $(build_depsbindir)/dsymutil$(EXE):
ln -svf "$(DSYMUTIL_PATH)" "$@"

# the following excludes: libuv.a, libutf8proc.a

ifneq ($(USE_SYSTEM_LIBM),0)
$(eval $(call symlink_system_library,LIBM,$(LIBMNAME)))
else ifneq ($(USE_SYSTEM_OPENLIBM),0)
$(eval $(call symlink_system_library,OPENLIBM,$(LIBMNAME)))
endif

#$(eval $(call symlink_system_library,LIBM,$(LIBMNAME)))
# On macOS, libgcc_s has soversion 1.1 always on aarch64 and only for GCC 12+
# (-> libgfortran 5) on x86_64
ifeq ($(OS),Darwin)
Expand Down
2 changes: 1 addition & 1 deletion base/linking.jl
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ function link_image_cmd(path, out)
LIBS = is_debug() ? ("-ljulia-debug", "-ljulia-internal-debug") :
("-ljulia", "-ljulia-internal")
@static if Sys.iswindows()
LIBS = (LIBS..., "-lopenlibm", "-lssp", "-lgcc_s", "-lgcc", "-lmsvcrt")
LIBS = (LIBS..., "-lssp", "-lgcc_s", "-lgcc", "-lmsvcrt")
end

V = VERBOSE[] ? "--verbose" : ""
Expand Down
3 changes: 0 additions & 3 deletions base/math.jl
Original file line number Diff line number Diff line change
Expand Up @@ -401,8 +401,6 @@ log(b::Number, x::Number) = log(promote(b,x)...)

# type specific math functions

const libm = Base.libm_name

# functions with no domain error
"""
sinh(x)
Expand Down Expand Up @@ -1207,7 +1205,6 @@ function rem(x::T, p::T, ::RoundingMode{:Nearest}) where T<:IEEEFloat
return flipsign(x, oldx)
end


"""
modf(x)
Expand Down
2 changes: 1 addition & 1 deletion contrib/julia-config.jl
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function ldlibs(doframework)
(Sys.isapple() ? string() : "-Wl,-rpath,$(shell_escape(private_libDir())) ") *
"-l$libname"
else
return "-l$libname -lopenlibm"
return "-l$libname -lm"
end
end

Expand Down
2 changes: 1 addition & 1 deletion contrib/refresh_checksums.mk
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ CLANG_TRIPLETS=$(filter %-darwin %-freebsd,$(TRIPLETS))
NON_CLANG_TRIPLETS=$(filter-out %-darwin %-freebsd,$(TRIPLETS))

# These are the projects currently using BinaryBuilder; both GCC-expanded and non-GCC-expanded:
BB_PROJECTS=mbedtls libssh2 nghttp2 mpfr curl libgit2 pcre libuv unwind llvmunwind dsfmt objconv p7zip zlib libsuitesparse openlibm blastrampoline libtracyclient
BB_PROJECTS=mbedtls libssh2 nghttp2 mpfr curl libgit2 pcre libuv unwind llvmunwind dsfmt objconv p7zip zlib libsuitesparse blastrampoline libtracyclient
BB_GCC_EXPANDED_PROJECTS=openblas csl
BB_CXX_EXPANDED_PROJECTS=gmp llvm clang llvm-tools lld
# These are non-BB source-only deps
Expand Down
13 changes: 3 additions & 10 deletions deps/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ BUILDDIR := $(BUILDDIR)$(MAYBE_HOST)
# if you are adding a new target, it can help to copy an similar, existing target
#
# autoconf configure-driven scripts: pcre unwind gmp mpfr patchelf libuv curl
# custom Makefile rules: openlibm dsfmt libsuitesparse lapack blastrampoline openblas utf8proc objconv libwhich
# custom Makefile rules: dsfmt libsuitesparse lapack blastrampoline openblas utf8proc objconv libwhich
# CMake libs: llvm llvmunwind libgit2 libssh2 mbedtls libtracyclient
#
# downloadable via git: llvm-svn, libuv, libopenlibm, utf8proc, libgit2, libssh2, libtracyclient
# downloadable via git: llvm-svn, libuv, utf8proc, libgit2, libssh2, libtracyclient
#
# to debug 'define' rules, replace eval at the usage site with info or error

Expand Down Expand Up @@ -82,12 +82,6 @@ PATCHELF_BIN := $(CUSTOM_LD_LIBRARY_PATH) $(PATCHELF)

## USE_SYSTEM_LIBS options

ifeq ($(USE_SYSTEM_OPENLIBM), 0)
ifeq ($(USE_SYSTEM_LIBM), 0)
DEP_LIBS += openlibm
endif
endif

ifeq ($(USE_SYSTEM_DSFMT), 0)
DEP_LIBS += dsfmt
endif
Expand Down Expand Up @@ -190,7 +184,7 @@ DEP_LIBS_STAGED := $(DEP_LIBS)

# list all targets
DEP_LIBS_STAGED_ALL := llvm llvm-tools clang llvmunwind unwind libuv pcre \
openlibm dsfmt blastrampoline openblas lapack gmp mpfr patchelf utf8proc \
dsfmt blastrampoline openblas lapack gmp mpfr patchelf utf8proc \
objconv mbedtls libssh2 nghttp2 curl libgit2 libwhich zlib p7zip csl \
sanitizers libsuitesparse lld libtracyclient ittapi JuliaSyntax
DEP_LIBS_ALL := $(DEP_LIBS_STAGED_ALL)
Expand Down Expand Up @@ -232,7 +226,6 @@ include $(SRCDIR)/ittapi.mk
include $(SRCDIR)/llvm.mk
include $(SRCDIR)/libuv.mk
include $(SRCDIR)/pcre.mk
include $(SRCDIR)/openlibm.mk
include $(SRCDIR)/dsfmt.mk
include $(SRCDIR)/objconv.mk
include $(SRCDIR)/blastrampoline.mk
Expand Down
34 changes: 0 additions & 34 deletions deps/checksums/openlibm

This file was deleted.

34 changes: 0 additions & 34 deletions deps/openlibm.mk

This file was deleted.

7 changes: 0 additions & 7 deletions deps/openlibm.version

This file was deleted.

2 changes: 0 additions & 2 deletions doc/src/devdocs/build/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ uses are listed in [`deps/$(libname).version`](https://github.com/JuliaLang/juli
- **[LLVM]** (15.0 + [patches](https://github.com/JuliaLang/llvm-project/tree/julia-release/15.x)) — compiler infrastructure (see [note below](#llvm)).
- **[FemtoLisp]** — packaged with Julia source, and used to implement the compiler front-end.
- **[libuv]** (custom fork) — portable, high-performance event-based I/O library.
- **[OpenLibm]** — portable libm library containing elementary math functions.
- **[DSFMT]** — fast Mersenne Twister pseudorandom number generator library.
- **[OpenBLAS]** — fast, open, and maintained [basic linear algebra subprograms (BLAS)]
- **[LAPACK]** — library of linear algebra routines for solving systems of simultaneous linear equations, least-squares solutions of linear systems of equations, eigenvalue problems, and singular value problems.
Expand Down Expand Up @@ -212,7 +211,6 @@ uses are listed in [`deps/$(libname).version`](https://github.com/JuliaLang/juli
[fetch]: https://www.freebsd.org/cgi/man.cgi?fetch(1)
[perl]: https://www.perl.org
[cmake]: https://www.cmake.org
[OpenLibm]: https://github.com/JuliaLang/openlibm
[DSFMT]: https://github.com/MersenneTwister-Lab/dSFMT
[OpenBLAS]: https://github.com/xianyi/OpenBLAS
[LAPACK]: https://www.netlib.org/lapack
Expand Down
2 changes: 1 addition & 1 deletion doc/src/manual/embedding.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ to the Julia installation before proceeding.
Using the project Properties dialog, go to `C/C++` | `General` and add `$(JULIA_DIR)\include\julia\` to the
Additional Include Directories property. Then, go to the `Linker` | `General` section and add `$(JULIA_DIR)\lib`
to the Additional Library Directories property. Finally, under `Linker` | `Input`, add `libjulia.dll.a;libopenlibm.dll.a;`
to the Additional Library Directories property. Finally, under `Linker` | `Input`, add `libjulia.dll.a;`
to the list of libraries.
At this point, the project should build and run.
Expand Down
17 changes: 0 additions & 17 deletions julia.spdx.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,18 +158,6 @@
"copyrightText": "Copyright (c) 2007, 2008, 2009 Mutsuo Saito, Makoto Matsumoto and Hiroshima University. Copyright (c) 2011, 2002 Mutsuo Saito, Makoto Matsumoto, Hiroshima University and The University of Tokyo.",
"summary": "Double precision SIMD-oriented Fast Mersenne Twister"
},
{
"name": "OpenLibm",
"SPDXID": "SPDXRef-OpenLibm",
"downloadLocation": "git+https://github.com/JuliaMath/openlibm.git",
"filesAnalyzed": false,
"homepage": "https://julialang.org",
"sourceInfo": "The git hash of the version in use can be found in the file deps/openlibm.version",
"licenseConcluded": "MIT",
"licenseDeclared": "MIT AND BSD-2-Clause-FreeBSD AND ISC",
"copyrightText": "Copyright (c) 2011-14 The Julia Project. Copyright (c) 2008 Stephen L. Moshier steve@moshier.net Copyright 1992-2011 The FreeBSD Project. All rights reserved. Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.",
"summary": "High quality system independent, portable, open source libm implementation"
},
{
"name": "GMP",
"SPDXID": "SPDXRef-GMP",
Expand Down Expand Up @@ -522,11 +510,6 @@
"relationshipType": "BUILD_DEPENDENCY_OF",
"relatedSpdxElement": "SPDXRef-JuliaMain"
},
{
"spdxElementId": "SPDXRef-OpenLibm",
"relationshipType": "BUILD_DEPENDENCY_OF",
"relatedSpdxElement": "SPDXRef-JuliaMain"
},
{
"spdxElementId": "SPDXRef-GMP",
"relationshipType": "BUILD_DEPENDENCY_OF",
Expand Down
1 change: 0 additions & 1 deletion pkgimage.mk
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ $(eval $(call stdlib_builder,LibUV_jll,Artifacts Libdl))
$(eval $(call stdlib_builder,LibUnwind_jll,Artifacts Libdl))
$(eval $(call stdlib_builder,MbedTLS_jll,Artifacts Libdl))
$(eval $(call stdlib_builder,nghttp2_jll,Artifacts Libdl))
$(eval $(call stdlib_builder,OpenLibm_jll,Artifacts Libdl))
$(eval $(call stdlib_builder,PCRE2_jll,Artifacts Libdl))
$(eval $(call stdlib_builder,Zlib_jll,Artifacts Libdl))
$(eval $(call stdlib_builder,dSFMT_jll,Artifacts Libdl))
Expand Down
Loading

0 comments on commit 028992f

Please sign in to comment.