Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 297 lines (245 sloc) 8.523 kb
39a7914 Introdue Daedalus, a new native code builder
Evan Phoenix authored
1 Daedalus.blueprint do |i|
c5a340b Add support for a system LLVM
Evan Phoenix authored
2 gcc = i.gcc!
3
48ba6b7 @stass - Move local include dirs to the first postition in CFLAGS. This
stass authored
4 gcc.cflags << "-Ivm -Ivm/test/cxxtest -I. "
f374b6d @ryoqun Add comment about -fno-omit-frame-pointer
ryoqun authored
5
6 # -fno-omit-frame-pointer is needed to get a backtrace on FreeBSD.
7 # It is enabled by default on OS X, on the other hand, not on Linux.
8 # To use same build flags across platforms, it is added explicitly.
c5a340b Add support for a system LLVM
Evan Phoenix authored
9 gcc.cflags << "-pipe -Wall -fno-omit-frame-pointer"
f374b6d @ryoqun Add comment about -fno-omit-frame-pointer
ryoqun authored
10
9f35409 @ryoqun Use -mno-omit-leaf-frame-pointer
ryoqun authored
11 # Due to a Clang bug (http://llvm.org/bugs/show_bug.cgi?id=9825),
12 # -mno-omit-leaf-frame-pointer is needed for Clang on Linux.
13 # On other combinations of platform and compiler, this flag is implicitly
14 # assumed from -fno-omit-frame-pointer. To use same build flags across
15 # platforms, -mno-omit-leaf-frame-pointer is added explicitly.
2e3d47b @brixen Use clang compile flag fix if using clang. Closes #1876.
brixen authored
16 gcc.cflags << "-mno-omit-leaf-frame-pointer" if Rubinius::BUILD_CONFIG[:cc] == "clang"
9f35409 @ryoqun Use -mno-omit-leaf-frame-pointer
ryoqun authored
17
c61c848 @dbussink Make sure to include -g flag and no warnings for unused functions
dbussink authored
18 gcc.cflags << "-Wno-unused-function"
3564fa1 @dbussink Only setup native debugging symbols by default
dbussink authored
19 gcc.cflags << "-g -Werror"
c5a340b Add support for a system LLVM
Evan Phoenix authored
20 gcc.cflags << "-DRBX_PROFILER"
e81ba74 @dbussink Fix building with LLVM disabled
dbussink authored
21 gcc.cflags << "-D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS"
29ff80a @dbussink Solaris build fixes
dbussink authored
22 gcc.cflags << "-D_LARGEFILE_SOURCE"
23 gcc.cflags << "-D_FILE_OFFSET_BITS=64"
c5a340b Add support for a system LLVM
Evan Phoenix authored
24
52a4d18 @steveklabnik Let's respect the CFLAGS a user sets.
steveklabnik authored
25 gcc.cflags << Rubinius::BUILD_CONFIG[:user_cflags]
26
c5a340b Add support for a system LLVM
Evan Phoenix authored
27 if ENV['DEV']
78da8b2 Fix for broken build on Apple Clang 4.0 (ML).
Chris Miller authored
28 gcc.cflags << "-O0"
0591393 @evanphx Teach daedalus to only use mtimes with DEV=1
evanphx authored
29 gcc.mtime_only = true
c5a340b Add support for a system LLVM
Evan Phoenix authored
30 else
31 gcc.cflags << "-O2"
32 end
33
3ceb20f @evanphx Fix 'for' in 1.9 mode
evanphx authored
34 if ENV['POKE']
35 gcc.mtime_only = true
36 end
37
1c8fc8a Merge remote branch 'origin/master' into hydra
Evan Phoenix authored
38 # This is necessary for the gcc sync prims to fully work
39 if Rubinius::BUILD_CONFIG[:x86_32]
40 gcc.cflags << "-march=i686"
41 end
42
c5a340b Add support for a system LLVM
Evan Phoenix authored
43 Rubinius::BUILD_CONFIG[:defines].each do |flag|
44 gcc.cflags << "-D#{flag}"
45 end
46
47 if RUBY_PLATFORM =~ /darwin/i
29ff80a @dbussink Solaris build fixes
dbussink authored
48 gcc.cflags << "-D_DARWIN_USE_64_BIT_INODE"
49
c5a340b Add support for a system LLVM
Evan Phoenix authored
50 if `sw_vers` =~ /10\.4/
51 gcc.cflags << "-DHAVE_STRLCAT -DHAVE_STRLCPY"
52 end
53
54 # This flag makes the executable non-relocatable (and
55 # slightly faster), but 4.3 does not support it.
56 # TODO: Look for workarounds.
57 unless `gcc -v 2>&1` =~ /gcc version 4\.3/i
58 gcc.cflags << "-mdynamic-no-pic"
59 end
60 end
61
e81ba74 @dbussink Fix building with LLVM disabled
dbussink authored
62 gcc.ldflags << "-lstdc++" << "-lm"
e558dac @brixen Only use include/lib paths that exist to build.
brixen authored
63
0220c11 @dbussink Allow configuring of additional include and lib dirs
dbussink authored
64 Rubinius::BUILD_CONFIG[:lib_dirs].each do |path|
e558dac @brixen Only use include/lib paths that exist to build.
brixen authored
65 gcc.ldflags << "-L#{path}" if File.exists? path
66 end
c5a340b Add support for a system LLVM
Evan Phoenix authored
67
457e27d @dbussink Store the make to use in a variable and default to gmake on *BSD plat…
dbussink authored
68 make = "make"
69
8ea6566 @brixen Changes to build on Windows.
brixen authored
70 # TODO: Fix with Platform object
56da88c Merge branch 'daedalus'
Evan Phoenix authored
71 case RUBY_PLATFORM
72 when /linux/i
e81ba74 @dbussink Fix building with LLVM disabled
dbussink authored
73 gcc.ldflags << '-Wl,--export-dynamic' << "-lrt" << "-lcrypt" << "-ldl" << "-lpthread"
944a6d1 @clee Fix build on FreeBSD - fixes #844
clee authored
74 when /freebsd/i
75 gcc.ldflags << '-lcrypt' << '-pthread' << '-rdynamic'
76 make = "gmake"
af3725a @brixen Fix from stu314 for building on NetBSD.
brixen authored
77 when /openbsd|netbsd/i
59e0f1d @jeremyevans Fix build on OpenBSD
jeremyevans authored
78 gcc.ldflags << '-lcrypto' << '-pthread' << '-lssl' << "-rdynamic" << "-Wl,--export-dynamic"
79 make = "gmake"
56da88c Merge branch 'daedalus'
Evan Phoenix authored
80 when /haiku/i
81 gcc.ldflags << "-ldl" << "-lnetwork"
82 when /bsd/i
83 gcc.ldflags << "-ldl" << "-lcrypt" << "-rdynamic"
457e27d @dbussink Store the make to use in a variable and default to gmake on *BSD plat…
dbussink authored
84 make = "gmake"
8ea6566 @brixen Changes to build on Windows.
brixen authored
85 when /mingw|win32/i
86 gcc.ldflags << "-lws2_32"
29ff80a @dbussink Solaris build fixes
dbussink authored
87 when /solaris/
4488cd9 @dbussink Add no-strict-aliasing on Solaris
dbussink authored
88 gcc.cflags << "-fPIC -Wno-strict-aliasing"
0659d96 @dbussink Don't use -G on Solaris for the executable
dbussink authored
89 gcc.ldflags << "-lsocket" << "-lnsl" << "-fPIC"
29ff80a @dbussink Solaris build fixes
dbussink authored
90 make = "gmake"
8ea6566 @brixen Changes to build on Windows.
brixen authored
91 else
e81ba74 @dbussink Fix building with LLVM disabled
dbussink authored
92 gcc.ldflags << "-ldl" << "-lpthread"
1c8fc8a Merge remote branch 'origin/master' into hydra
Evan Phoenix authored
93 end
94
56da88c Merge branch 'daedalus'
Evan Phoenix authored
95 if RUBY_PLATFORM =~ /bsd/ and
96 Rubinius::BUILD_CONFIG[:defines].include?('HAS_EXECINFO')
97 gcc.ldflags << "-lexecinfo"
98 end
c5a340b Add support for a system LLVM
Evan Phoenix authored
99
06cb2e3 @r-stu31 Add LDFLAGS from envionment to ldflags used for building vm.
r-stu31 authored
100 gcc.ldflags << Rubinius::BUILD_CONFIG[:user_ldflags]
101
c5a340b Add support for a system LLVM
Evan Phoenix authored
102 # Files
8ea6566 @brixen Changes to build on Windows.
brixen authored
103 subdirs = %w[ builtin capi util instruments gc llvm missing ].map do |x|
c5a340b Add support for a system LLVM
Evan Phoenix authored
104 "vm/#{x}/*.{cpp,c}"
105 end
106
107 files = i.source_files "vm/*.{cpp,c}", *subdirs
108
c4c2fd4 Use the proper perl when needed
Evan Phoenix authored
109 perl = Rubinius::BUILD_CONFIG[:build_perl] || "perl"
110
c5a340b Add support for a system LLVM
Evan Phoenix authored
111 # Libraries
eff4aa4 @brixen Changed references from vm/external_libs to vendor.
brixen authored
112 ltm = i.external_lib "vendor/libtommath" do |l|
113 l.cflags = ["-Ivendor/libtommath"]
39a7914 Introdue Daedalus, a new native code builder
Evan Phoenix authored
114 l.objects = [l.file("libtommath.a")]
115 l.to_build do |x|
457e27d @dbussink Store the make to use in a variable and default to gmake on *BSD plat…
dbussink authored
116 x.command make
39a7914 Introdue Daedalus, a new native code builder
Evan Phoenix authored
117 end
118 end
119
a080a18 @brixen Build oniguruma with daedalus.
brixen authored
120 oniguruma = i.library_group "vendor/oniguruma" do |g|
121 g.depends_on "config.h", "configure"
122
123 gcc.cflags << "-Ivendor/oniguruma"
124 g.cflags = ["-DHAVE_CONFIG_H", "-I.", "-I../../vm/capi/19/include"]
125
126 g.static_library "libonig" do |l|
127 l.source_files "*.c", "enc/*.c"
39a7914 Introdue Daedalus, a new native code builder
Evan Phoenix authored
128 end
a080a18 @brixen Build oniguruma with daedalus.
brixen authored
129
130 g.shared_library "enc/trans/big5"
131 g.shared_library "enc/trans/chinese"
132 g.shared_library "enc/trans/emoji"
133 g.shared_library "enc/trans/emoji_iso2022_kddi"
134 g.shared_library "enc/trans/emoji_sjis_docomo"
135 g.shared_library "enc/trans/emoji_sjis_kddi"
136 g.shared_library "enc/trans/emoji_sjis_softbank"
137 g.shared_library "enc/trans/escape"
138 g.shared_library "enc/trans/gb18030"
139 g.shared_library "enc/trans/gbk"
140 g.shared_library "enc/trans/iso2022"
141 g.shared_library "enc/trans/japanese"
142 g.shared_library "enc/trans/japanese_euc"
143 g.shared_library "enc/trans/japanese_sjis"
144 g.shared_library "enc/trans/korean"
145 g.shared_library "enc/trans/newline"
146 g.shared_library "enc/trans/single_byte"
147 g.shared_library "enc/trans/utf8_mac"
148 g.shared_library "enc/trans/utf_16_32"
39a7914 Introdue Daedalus, a new native code builder
Evan Phoenix authored
149 end
150
eff4aa4 @brixen Changed references from vm/external_libs to vendor.
brixen authored
151 gdtoa = i.external_lib "vendor/libgdtoa" do |l|
152 l.cflags = ["-Ivendor/libgdtoa"]
39a7914 Introdue Daedalus, a new native code builder
Evan Phoenix authored
153 l.objects = [l.file("libgdtoa.a")]
154 l.to_build do |x|
457e27d @dbussink Store the make to use in a variable and default to gmake on *BSD plat…
dbussink authored
155 x.command make
39a7914 Introdue Daedalus, a new native code builder
Evan Phoenix authored
156 end
157 end
158
eff4aa4 @brixen Changed references from vm/external_libs to vendor.
brixen authored
159 ffi = i.external_lib "vendor/libffi" do |l|
160 l.cflags = ["-Ivendor/libffi/include"]
39a7914 Introdue Daedalus, a new native code builder
Evan Phoenix authored
161 l.objects = [l.file(".libs/libffi.a")]
162 l.to_build do |x|
51db937 @dbussink Disable custom build dir for libffi
dbussink authored
163 x.command "sh -c './configure --disable-builddir'" unless File.exists?("Makefile")
457e27d @dbussink Store the make to use in a variable and default to gmake on *BSD plat…
dbussink authored
164 x.command make
39a7914 Introdue Daedalus, a new native code builder
Evan Phoenix authored
165 end
166 end
167
eff4aa4 @brixen Changed references from vm/external_libs to vendor.
brixen authored
168 udis = i.external_lib "vendor/udis86" do |l|
169 l.cflags = ["-Ivendor/udis86"]
39a7914 Introdue Daedalus, a new native code builder
Evan Phoenix authored
170 l.objects = [l.file("libudis86/.libs/libudis86.a")]
171 l.to_build do |x|
23ae6a6 Rerun configure for udis
Evan Phoenix authored
172 unless File.exists?("Makefile") and File.exists?("libudis86/Makefile")
3460bed @brixen Use Windows-friendly command lines for configure.
brixen authored
173 x.command "sh -c ./configure"
23ae6a6 Rerun configure for udis
Evan Phoenix authored
174 end
457e27d @dbussink Store the make to use in a variable and default to gmake on *BSD plat…
dbussink authored
175 x.command make
39a7914 Introdue Daedalus, a new native code builder
Evan Phoenix authored
176 end
177 end
178
4a8b9a4 @brixen Added --with[out]-vendor-zlib to configure.
brixen authored
179 if Rubinius::BUILD_CONFIG[:vendor_zlib]
eff4aa4 @brixen Changed references from vm/external_libs to vendor.
brixen authored
180 zlib = i.external_lib "vendor/zlib" do |l|
181 l.cflags = ["-Ivendor/zlib"]
4a8b9a4 @brixen Added --with[out]-vendor-zlib to configure.
brixen authored
182 l.objects = []
183 l.to_build do |x|
184 unless File.exists?("Makefile") and File.exists?("zconf.h")
185 x.command "sh -c ./configure"
186 end
fe73d44 @brixen Fixed building zlib on Windows.
brixen authored
187
4a8b9a4 @brixen Added --with[out]-vendor-zlib to configure.
brixen authored
188 if Rubinius::BUILD_CONFIG[:windows]
189 x.command "make -f win32/Makefile.gcc"
190 else
191 x.command make
192 end
fe73d44 @brixen Fixed building zlib on Windows.
brixen authored
193 end
50a9cde @brixen Add zlib to build.
brixen authored
194 end
195 end
1c8fc8a Merge remote branch 'origin/master' into hydra
Evan Phoenix authored
196
53b887d @Gibheer fix the order of include paths
Gibheer authored
197 case Rubinius::BUILD_CONFIG[:llvm]
198 when :prebuilt, :svn
199 llvm = i.external_lib "vendor/llvm" do |l|
abe162e @dbussink Allow for a binary llvm-config
dbussink authored
200 l.cflags = ["-Ivendor/llvm/include"]
201 l.objects = []
53b887d @Gibheer fix the order of include paths
Gibheer authored
202 end
203
204 gcc.add_library llvm
abe162e @dbussink Allow for a binary llvm-config
dbussink authored
205 end
206
207 case Rubinius::BUILD_CONFIG[:llvm]
208 when :config, :prebuilt, :svn
53b887d @Gibheer fix the order of include paths
Gibheer authored
209 conf = Rubinius::BUILD_CONFIG[:llvm_configure]
abe162e @dbussink Allow for a binary llvm-config
dbussink authored
210 flags = `#{conf} --cflags`.strip.split(/\s+/)
53b887d @Gibheer fix the order of include paths
Gibheer authored
211 flags.delete_if { |x| x.index("-O") == 0 }
212 flags.delete_if { |x| x =~ /-D__STDC/ }
213 flags.delete_if { |x| x == "-DNDEBUG" }
39b9e7a @dbussink Make sure LLVM config doesn't set -fomit-frame-pointer
dbussink authored
214 flags.delete_if { |x| x == "-fomit-frame-pointer" }
da175c5 @tonysidaway Filter out over-strict llvm-config --cxxflags flags encountered on Op…
tonysidaway authored
215 flags.delete_if { |x| x == "-pedantic" }
216 flags.delete_if { |x| x == "-W" }
217 flags.delete_if { |x| x == "-Wextra" }
39b9e7a @dbussink Make sure LLVM config doesn't set -fomit-frame-pointer
dbussink authored
218
53b887d @Gibheer fix the order of include paths
Gibheer authored
219 flags << "-DENABLE_LLVM"
abe162e @dbussink Allow for a binary llvm-config
dbussink authored
220
221 ldflags = `#{conf} --ldflags`.strip.split(/\s+/)
222 objects = `#{conf} --libfiles`.strip.split(/\s+/)
223
224 if Rubinius::BUILD_CONFIG[:windows]
225 ldflags = ldflags.sub(%r[-L/([a-zA-Z])/], '-L\1:/')
226
227 objects.select do |f|
228 f.sub!(%r[^/([a-zA-Z])/], '\1:/')
229 File.file? f
230 end
231 end
232
53b887d @Gibheer fix the order of include paths
Gibheer authored
233 gcc.cflags.concat flags
abe162e @dbussink Allow for a binary llvm-config
dbussink authored
234 gcc.ldflags.concat ldflags
235 gcc.ldflags.concat objects
53b887d @Gibheer fix the order of include paths
Gibheer authored
236 when :no
237 # nothing, not using LLVM
238 else
239 STDERR.puts "Unsupported LLVM configuration: #{Rubinius::BUILD_CONFIG[:llvm]}"
240 raise "get out"
241 end
242
4a8b9a4 @brixen Added --with[out]-vendor-zlib to configure.
brixen authored
243 gcc.add_library zlib if Rubinius::BUILD_CONFIG[:vendor_zlib]
39a7914 Introdue Daedalus, a new native code builder
Evan Phoenix authored
244 gcc.add_library udis
245 gcc.add_library ffi
246 gcc.add_library gdtoa
247 gcc.add_library ltm
248
0220c11 @dbussink Allow configuring of additional include and lib dirs
dbussink authored
249 Rubinius::BUILD_CONFIG[:include_dirs].each do |path|
e558dac @brixen Only use include/lib paths that exist to build.
brixen authored
250 gcc.cflags << "-I#{path} " if File.exists? path
251 end
48ba6b7 @stass - Move local include dirs to the first postition in CFLAGS. This
stass authored
252
8ea6566 @brixen Changes to build on Windows.
brixen authored
253 if Rubinius::BUILD_CONFIG[:windows]
eff4aa4 @brixen Changed references from vm/external_libs to vendor.
brixen authored
254 winp = i.external_lib "vendor/winpthreads" do |l|
255 l.cflags = ["-Ivendor/winpthreads/include"]
1c8fc8a Merge remote branch 'origin/master' into hydra
Evan Phoenix authored
256 l.objects = [l.file("libpthread.a")]
257 l.to_build do |x|
3460bed @brixen Use Windows-friendly command lines for configure.
brixen authored
258 x.command "sh -c ./configure" unless File.exists?("Makefile")
457e27d @dbussink Store the make to use in a variable and default to gmake on *BSD plat…
dbussink authored
259 x.command make
1c8fc8a Merge remote branch 'origin/master' into hydra
Evan Phoenix authored
260 end
261 end
262
263 gcc.add_library winp
8ea6566 @brixen Changes to build on Windows.
brixen authored
264
265 files << winp
1c8fc8a Merge remote branch 'origin/master' into hydra
Evan Phoenix authored
266 end
267
4a8b9a4 @brixen Added --with[out]-vendor-zlib to configure.
brixen authored
268 files << zlib if Rubinius::BUILD_CONFIG[:vendor_zlib]
39a7914 Introdue Daedalus, a new native code builder
Evan Phoenix authored
269 files << udis
270 files << ffi
271 files << gdtoa
efa3a58 @brixen Use vendor/oniguruma.
brixen authored
272 files << oniguruma
39a7914 Introdue Daedalus, a new native code builder
Evan Phoenix authored
273 files << ltm
274
275 cli = files.dup
276 cli << i.source_file("vm/drivers/cli.cpp")
277
1c8fc8a Merge remote branch 'origin/master' into hydra
Evan Phoenix authored
278 exe = RUBY_PLATFORM =~ /mingw|mswin/ ? 'vm/vm.exe' : 'vm/vm'
279 i.program exe, *cli
39a7914 Introdue Daedalus, a new native code builder
Evan Phoenix authored
280
281 test_files = files.dup
282 test_files << i.source_file("vm/test/runner.cpp") { |f|
1ec8099 Fixes found on linux
Evan Phoenix authored
283 tests = Dir["vm/test/**/test_*.hpp"].sort
39a7914 Introdue Daedalus, a new native code builder
Evan Phoenix authored
284
285 f.depends_on tests
286
287 f.autogenerate do |x|
c4c2fd4 Use the proper perl when needed
Evan Phoenix authored
288 x.command("#{perl} vm/test/cxxtest/cxxtestgen.pl --error-printer --have-eh " +
39a7914 Introdue Daedalus, a new native code builder
Evan Phoenix authored
289 "--abort-on-fail -include=string.h -include=stdlib.h " +
290 "-include=vm/test/test_setup.h -o vm/test/runner.cpp " +
291 tests.join(' '))
292 end
293 }
294
295 i.program "vm/test/runner", *test_files
296 end
Something went wrong with that request. Please try again.