-
Notifications
You must be signed in to change notification settings - Fork 508
/
build_tarballs.jl
151 lines (126 loc) · 4.94 KB
/
build_tarballs.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# Note that this script can accept some limited command-line arguments, run
# `julia build_tarballs.jl --help` to see a usage message.
using BinaryBuilder, Pkg
# The version of this JLL is decoupled from the upstream version.
# Whenever we package a new upstream release, we initially map its
# version X.Y.Z to X00.Y00.Z00 (i.e., multiply each component by 100).
# So for example version 2.6.3 would become 200.600.300.
#
# Moreover, all our packages using this JLL use `~` in their compat ranges.
#
# Together, this allows us to increment the patch level of the JLL for minor tweaks.
# If a rebuild of the JLL is needed which keeps the upstream version identical
# but breaks ABI compatibility for any reason, we can increment the minor version
# e.g. go from 200.600.300 to 200.601.300.
# To package prerelease versions, we can also adjust the minor version; e.g. we may
# map a prerelease of 2.7.0 to 200.690.000.
#
# There is currently no plan to change the major version, except when upstream itself
# changes its major version. It simply seemed sensible to apply the same transformation
# to all components.
# See https://github.com/JuliaLang/Pkg.jl/issues/2942
# Once this Pkg issue is resolved, this must be removed
uuid = Base.UUID("a83860b7-747b-57cf-bf1f-3e79990d037f")
delete!(Pkg.Types.get_last_stdlibs(v"1.6.3"), uuid)
name = "GAP"
upstream_version = v"4.12.2"
version = v"400.1200.200"
julia_versions = [v"1.6.3", v"1.7", v"1.8", v"1.9", v"1.10"]
# Collection of sources required to complete build
sources = [
ArchiveSource("https://github.com/gap-system/gap/releases/download/v$(upstream_version)/gap-$(upstream_version)-core.tar.gz",
"5d73e77f0b2bbe8dd0233dfad48666aeb1fcbffd84c5dbb58c8ea2a8dd9687b5"),
DirectorySource("./bundled"),
]
# Bash recipe for building across all platforms
script = raw"""
cd ${WORKSPACE}/srcdir/gap*
for f in ${WORKSPACE}/srcdir/patches/*.patch; do
atomic_patch -p1 ${f}
done
# HACK: determine Julia version
cat > version.c <<EOF
#include <stdio.h>
#include "julia/julia_version.h"
int main(int argc, char**argv)
{
printf("%d.%d", JULIA_VERSION_MAJOR, JULIA_VERSION_MINOR);
return 0;
}
EOF
${CC_BUILD} -Wall version.c -o julia_version
julia_version=$(./julia_version)
# must run autogen.sh if compiling from git snapshot and/or if configure was patched;
# it doesn't hurt otherwise, too, so just always do it
./autogen.sh
# configure GAP
./configure --prefix=${prefix} --build=${MACHTYPE} --host=${target} \
JULIA_VERSION="$julia_version" \
--with-gmp=${prefix} \
--with-readline=${prefix} \
--with-zlib=${prefix} \
--with-gc=julia \
--with-julia
# WORKAROUND: avoid error: /usr/local/include: No such file or directory
export CPPFLAGS="$CPPFLAGS -Wno-missing-include-dirs"
# When building a git snapshot, configure & compile a native version of GAP to
# generate ffdata.{c,h}, c_oper1.c and c_type1.c -- in a GAP release tarball
# this is not necessary.
if [ ! -f src/c_oper1.c ] ; then
mkdir native-build
cd native-build
../configure --build=${MACHTYPE} --host=${MACHTYPE} \
--enable-Werror \
--with-gmp=${host_prefix} \
--without-readline \
--with-zlib=${host_prefix} \
CC=${CC_BUILD} CXX=${CXX_BUILD}
make -j${nproc}
cp build/c_*.c build/ffdata.* ../src/
cd ..
# remove the native build, it has done its job
rm -rf native-build
fi
# compile GAP
make -j${nproc}
# install GAP binaries, headers, shared library, sysinfo
make install-bin install-headers install-libgap install-sysinfo
# the license
install_license LICENSE
# We deliberately do NOT install the GAP library, documentation, etc. because
# they are identical across all platforms; instead, we use another platform
# independent artifact to ship them to the user.
"""
include("../../L/libjulia/common.jl")
platforms = vcat(libjulia_platforms.(julia_versions)...)
filter!(!Sys.iswindows, platforms)
# we only care about 64bit builds
filter!(p -> nbits(p) == 64, platforms)
# Windows is not supported
filter!(!Sys.iswindows, platforms)
# The products that we will ensure are always built
products = [
ExecutableProduct("gap", :gap),
LibraryProduct("libgap", :libgap),
]
# Dependencies that must be installed before this package can be built
dependencies = [
# for the "native" build that generates c_oper1.c and c_type1.c
HostBuildDependency("GMP_jll"),
HostBuildDependency("Zlib_jll"),
Dependency("GMP_jll"),
Dependency("Readline_jll"),
Dependency("Zlib_jll"),
BuildDependency("libjulia_jll"),
]
# Build the tarballs.
build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies;
preferred_gcc_version=v"7", julia_compat="1.6", init_block="""
try
cglobal(:jl_reinit_foreign_type)
catch
# no jl_reinit_foreign_type -> fall back to old behavior
sym = dlsym(libgap_handle, :GAP_InitJuliaMemoryInterface)
ccall(sym, Nothing, (Any, Ptr{Nothing}), @__MODULE__, C_NULL)
end
""")