rake-compiler-dock 1.0.1 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/.github/workflows/ci.yml +168 -0
  4. data/.gitignore +11 -1
  5. data/Dockerfile.jruby +7 -6
  6. data/Dockerfile.mri.erb +170 -73
  7. data/History.md +42 -0
  8. data/README.md +95 -36
  9. data/Rakefile +45 -10
  10. data/build/math_h.patch +189 -0
  11. data/build/parallel_docker_build.rb +7 -3
  12. data/build/patches/{ruby-2.5.7 → ruby-2.5.9}/no_sendfile.patch +0 -0
  13. data/build/patches/{ruby-2.7.0 → ruby-3.1.0}/no_sendfile.patch +6 -6
  14. data/build/patches2/rake-compiler-1.1.6/0004-Enable-build-of-static-libruby.patch +28 -0
  15. data/build/rcd-env.sh +6 -0
  16. data/build/runas +1 -8
  17. data/build/sudoers +1 -1
  18. data/lib/rake_compiler_dock/starter.rb +3 -2
  19. data/lib/rake_compiler_dock/version.rb +2 -2
  20. data/mingw64-ucrt/Dockerfile +62 -0
  21. data/mingw64-ucrt/binutils-mingw-w64-ignore-check-errors.patch +13 -0
  22. data/mingw64-ucrt/gcc-mingw-w64-only-c-c++.patch +13 -0
  23. data/mingw64-ucrt/mingw-w64-enable-ucrt.patch +22 -0
  24. data/rake-compiler-dock.gemspec +2 -2
  25. data/test/env/Dockerfile.alpine +17 -0
  26. data/test/env/Dockerfile.centos +22 -0
  27. data/test/env/Dockerfile.debian +24 -0
  28. data/test/rcd_test/Gemfile +11 -0
  29. data/test/rcd_test/Rakefile +75 -0
  30. data/test/rcd_test/ext/java/RcdTestExtService.java +19 -0
  31. data/test/rcd_test/ext/java/RubyRcdTest.java +16 -0
  32. data/test/rcd_test/ext/mri/extconf.rb +23 -0
  33. data/test/rcd_test/ext/mri/rcd_test_ext.c +51 -0
  34. data/test/rcd_test/ext/mri/rcd_test_ext.h +6 -0
  35. data/test/rcd_test/lib/rcd_test.rb +6 -0
  36. data/test/rcd_test/rcd_test.gemspec +27 -0
  37. data/test/rcd_test/test/test_basic.rb +31 -0
  38. data/test/test_environment_variables.rb +56 -31
  39. data/test/test_parallel_docker_build.rb +19 -6
  40. data.tar.gz.sig +0 -0
  41. metadata +79 -19
  42. metadata.gz.sig +0 -0
  43. data/build/patches2/hoe-3.20.0/0001-Load-encrypted-private-key-using-ENV-GEM_PRIVATE_KEY.patch +0 -32
  44. data/build/patches2/rake-compiler-1.1.0/0001-Allow-parallel-builds-of-cross-rubies.patch +0 -119
  45. data/build/patches2/rake-compiler-1.1.0/0001-Enable-build-of-static-libruby.patch +0 -28
  46. data/build/patches2/rake-compiler-1.1.0/0001-Fix-determining-of-ruby-versions-in-rake-native-gem.patch +0 -44
  47. data/build/patches2/rake-compiler-1.1.0/0002-Extend-mingw-search-pattern-to-find-x86_64-gcc.patch +0 -26
  48. data/build/patches2/rake-compiler-1.1.0/0002-Strip-cross-built-shared-library-files-while-linking.patch +0 -29
  49. data/build/patches2/ruby-2.7.0/ruby2_keywords.patch +0 -15
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # rake-compiler-dock
2
2
 
3
- **Easy to use and reliable cross compiler environment for building Windows, Linux and JRuby binary gems.**
3
+ **Easy to use and reliable cross compiler environment for building Windows, Linux, Mac and JRuby binary gems.**
4
4
 
5
- It provides cross compilers and Ruby environments for 2.2 and newer versions of the [RubyInstaller](http://rubyinstaller.org/) and Linux runtime environments.
5
+ It provides cross compilers and Ruby environments for 2.4 and newer versions of the [RubyInstaller](http://rubyinstaller.org/) and Linux runtime environments.
6
6
  They are prepared for use with [rake-compiler](https://github.com/rake-compiler/rake-compiler).
7
7
  It is used by [many gems with C or JRuby extentions](https://github.com/rake-compiler/rake-compiler-dock/wiki/Projects-using-rake-compiler-dock).
8
8
 
@@ -12,11 +12,7 @@ It is also more reliable, since the underlying docker images are versioned and i
12
12
 
13
13
  ## Installation
14
14
 
15
- Install docker natively on Linux:
16
-
17
- $ sudo apt-get install docker.io
18
-
19
- ... or install [docker-toolbox for Windows and OSX](https://github.com/docker/toolbox/releases) or boot2docker on [Windows](https://github.com/boot2docker/windows-installer/releases) or [OS X](https://github.com/boot2docker/osx-installer/releases) .
15
+ Install docker [following the instructions on the docker website](https://docs.docker.com/engine/install/) ... or install [docker-toolbox for Windows and OSX](https://github.com/docker/toolbox/releases) or boot2docker on [Windows](https://github.com/boot2docker/windows-installer/releases) or [OS X](https://github.com/boot2docker/osx-installer/releases) .
20
16
 
21
17
  Install rake-compiler-dock as a gem. The docker image is downloaded later on demand:
22
18
 
@@ -34,10 +30,12 @@ Rake-compiler-dock provides the necessary tools to build Ruby extensions for Win
34
30
  It is intended to be used in conjunction with [rake-compiler's](https://github.com/rake-compiler/rake-compiler) cross build capability.
35
31
  Your Rakefile should enable cross compilation like so:
36
32
 
37
- exttask = Rake::ExtensionTask.new('my_extension', my_gem_spec) do |ext|
38
- ext.cross_compile = true
39
- ext.cross_platform = %w[x86-mingw32 x64-mingw32 x86-linux x86_64-linux]
40
- end
33
+ ```ruby
34
+ exttask = Rake::ExtensionTask.new('my_extension', my_gem_spec) do |ext|
35
+ ext.cross_compile = true
36
+ ext.cross_platform = %w[x86-mingw32 x64-mingw-ucrt x64-mingw32 x86-linux x86_64-linux x86_64-darwin arm64-darwin]
37
+ end
38
+ ```
41
39
 
42
40
  See below, how to invoke cross builds in your Rakefile.
43
41
 
@@ -46,7 +44,9 @@ Additionally it may also be used to build ffi based binary gems like [libusb](ht
46
44
  ### Interactive Usage
47
45
 
48
46
  Rake-compiler-dock offers the shell command `rake-compiler-dock` and a [ruby API](http://www.rubydoc.info/gems/rake-compiler-dock/RakeCompilerDock) for issuing commands within the docker image, described below.
49
- There dedicated are images for `x86-mingw32`, `x64-mingw32`, `x86-linux`, `x86_64-linux` and `jruby` targets.
47
+ There are dedicated images for `x86-mingw32`, `x64-mingw-ucrt`, `x64-mingw32`, `x86-linux`, `x86_64-linux`, `x86_64-darwin`, `arm64-darwin` and `jruby` targets.
48
+ The images contain all supported cross ruby versions, with the exception of `x64-mingw32`, which has versions before 3.1 only, and `x64-mingw-ucrt`, which has only ruby-3.1+.
49
+ This is to match the [changed platform of RubyInstaller-3.1](https://rubyinstaller.org/2021/12/31/rubyinstaller-3.1.0-1-released.html).
50
50
 
51
51
  `rake-compiler-dock` without arguments starts an interactive shell session.
52
52
  This is best suited to try out and debug a build.
@@ -81,13 +81,64 @@ Or non-interactive:
81
81
 
82
82
  The environment variable `RUBY_CC_VERSION` is predefined as described [below](#environment-variables).
83
83
 
84
- If necessary, additional software from the Ubuntu repositories can be installed, prior to the build command.
85
- This is local to the running session, only:
84
+ If necessary, additional software can be installed, prior to the build command.
85
+ This is local to the running session, only.
86
+
87
+ For Windows and Mac:
86
88
 
87
89
  sudo apt-get update && sudo apt-get install your-package
88
90
 
91
+ For Linux:
92
+
93
+ sudo yum install your-package
94
+
89
95
  You can also choose between different executable ruby versions by `rvm use <version>` .
90
- The current default is 2.5.
96
+ The current default is 3.1.
97
+
98
+
99
+ ### As a CI System Container
100
+
101
+ The OCI images provided by rake-compiler-dock can be used without the `rake-compiler-dock` gem or wrapper. This may be useful if your CI pipeline is building native gems.
102
+
103
+ For example, a Github Actions job might look like this:
104
+
105
+ ``` yaml
106
+ jobs:
107
+ native-gem:
108
+ name: "native-gem"
109
+ runs-on: ubuntu-latest
110
+ container:
111
+ image: "larskanis/rake-compiler-dock-mri-x86_64-linux:1.2.1"
112
+ steps:
113
+ - uses: actions/checkout@v2
114
+ - run: bundle install && bundle exec rake gem:x86_64-linux:rcd
115
+ - uses: actions/upload-artifact@v2
116
+ with:
117
+ name: native-gem
118
+ path: gems
119
+ retention-days: 1
120
+ ```
121
+
122
+ Where the referenced rake task might be defined by:
123
+
124
+ ``` ruby
125
+ cross_platforms = ["x64-mingw32", "x86_64-linux", "x86_64-darwin", "arm64-darwin"]
126
+
127
+ namespace "gem" do
128
+ cross_platforms.each do |platform|
129
+ namespace platform do
130
+ task "rcd" do
131
+ Rake::Task["native:#{platform}"].invoke
132
+ Rake::Task["pkg/#{rcee_precompiled_spec.full_name}-#{Gem::Platform.new(platform)}.gem"].invoke
133
+ end
134
+ end
135
+ end
136
+ end
137
+
138
+ ```
139
+
140
+ For an example of rake tasks that support this style of invocation, visit https://github.com/flavorjones/ruby-c-extensions-explained/tree/main/precompiled
141
+
91
142
 
92
143
  ### JRuby support
93
144
 
@@ -111,17 +162,19 @@ To build java binary gems interactively, it can be called like this:
111
162
  To make the build process reproducible for other parties, it is recommended to add rake-compiler-dock to your Rakefile.
112
163
  This can be done like this:
113
164
 
114
- task 'gem:native' do
115
- require 'rake_compiler_dock'
116
- sh "bundle package" # Avoid repeated downloads of gems by using gem files from the host.
117
- %w[ x86-mingw32 x64-mingw32 x86-linux x86_64-linux ].each do |plat|
118
- RakeCompilerDock.sh "bundle --local && rake native:#{plat} gem", platform: plat
119
- end
120
- RakeCompilerDock.sh "bundle --local && rake java gem", rubyvm: :jruby
121
- end
165
+ ```ruby
166
+ task 'gem:native' do
167
+ require 'rake_compiler_dock'
168
+ sh "bundle package --all" # Avoid repeated downloads of gems by using gem files from the host.
169
+ %w[ x86-mingw32 x64-mingw-ucrt x64-mingw32 x86-linux x86_64-linux arm-linux aarch64-linux x86_64-darwin arm64-darwin ].each do |plat|
170
+ RakeCompilerDock.sh "bundle --local && rake native:#{plat} gem", platform: plat
171
+ end
172
+ RakeCompilerDock.sh "bundle --local && rake java gem", rubyvm: :jruby
173
+ end
174
+ ```
122
175
 
123
176
  This runs the `bundle` and `rake` commands once for each platform.
124
- That is once for the jruby gems and 4 times for the specified MRI platforms.
177
+ That is once for the jruby gems and 6 times for the specified MRI platforms.
125
178
 
126
179
  ### Run builds in parallel
127
180
 
@@ -133,17 +186,19 @@ Please note, that parallel builds only work reliable, if the specific platform g
133
186
 
134
187
  ```ruby
135
188
  namespace "gem" do
189
+ task 'prepare' do
190
+ require 'rake_compiler_dock'
191
+ require 'io/console'
192
+ sh "bundle package --all"
193
+ sh "cp ~/.gem/gem-*.pem build/gem/ || true"
194
+ ENV["GEM_PRIVATE_KEY_PASSPHRASE"] = STDIN.getpass("Enter passphrase of gem signature key: ")
195
+ end
196
+
136
197
  exttask.cross_platform.each do |plat|
137
- desc "Build the native binary gems"
198
+ desc "Build all native binary gems in parallel"
138
199
  multitask 'native' => plat
139
200
 
140
- task 'prepare' do
141
- require 'rake_compiler_dock'
142
- sh "cp ~/.gem/gem-*.pem build/gem/ || true"
143
- require 'io/console'
144
- ENV["GEM_PRIVATE_KEY_PASSPHRASE"] = STDIN.getpass("Enter passphrase of gem signature key: ")
145
- end
146
-
201
+ desc "Build the native gem for #{plat}"
147
202
  task plat => 'prepare' do
148
203
  RakeCompilerDock.sh <<-EOT, platform: plat
149
204
  (cp build/gem/gem-*.pem ~/.gem/ || true) &&
@@ -159,7 +214,9 @@ Please note, that parallel builds only work reliable, if the specific platform g
159
214
 
160
215
  Rake-compiler-dock uses [semantic versioning](http://semver.org/), so you should add it into your Gemfile, to make sure, that future changes will not break your build.
161
216
 
162
- gem 'rake-compiler-dock', '~> 1.0'
217
+ ```ruby
218
+ gem 'rake-compiler-dock', '~> 1.2'
219
+ ```
163
220
 
164
221
  See [the wiki](https://github.com/rake-compiler/rake-compiler-dock/wiki/Projects-using-rake-compiler-dock) for projects which make use of rake-compiler-dock.
165
222
 
@@ -173,7 +230,7 @@ The following variables are recognized by rake-compiler-dock:
173
230
  * `RCD_RUBYVM` - The ruby VM and toolchain to be used.
174
231
  Must be one of `mri`, `jruby`.
175
232
  * `RCD_PLATFORM` - The target rubygems platform.
176
- Must be a space separated list out of `x86-mingw32`, `x64-mingw32`, `x86-linux` and `x86_64-linux`.
233
+ Must be a space separated list out of `x86-mingw32`, `x64-mingw-ucrt`, `x64-mingw32`, `x86-linux`, `x86_64-linux`, `arm-linux`, `aarch64-linux`, `x86_64-darwin` and `arm64-darwin`.
177
234
  It is ignored when `rubyvm` is set to `:jruby`.
178
235
  * `RCD_IMAGE` - The docker image that is downloaded and started.
179
236
  Defaults to "larskanis/rake-compiler-dock:IMAGE_VERSION" with an image version that is determined by the gem version.
@@ -189,7 +246,7 @@ The following variables are provided to the running docker container:
189
246
  * `RCD_HOST_RUBY_PLATFORM` - The `RUBY_PLATFORM` of the host ruby.
190
247
  * `RCD_HOST_RUBY_VERSION` - The `RUBY_VERSION` of the host ruby.
191
248
  * `RUBY_CC_VERSION` - The target ruby versions for rake-compiler.
192
- The default is defined in the [Dockerfile](https://github.com/rake-compiler/rake-compiler-dock/blob/master/Dockerfile), but can be changed as a parameter to rake.
249
+ The default is defined in the [Dockerfile](https://github.com/rake-compiler/rake-compiler-dock/blob/94770238d68d71df5f70abe76097451a575ce46c/Dockerfile.mri.erb#L229), but can be changed as a parameter to rake.
193
250
  * `RCD_MOUNTDIR` - The directory which is mounted into the docker container.
194
251
  Defaults to pwd.
195
252
  * `RCD_WORKDIR` - The working directory within the docker container.
@@ -197,7 +254,9 @@ The following variables are provided to the running docker container:
197
254
 
198
255
  Other environment variables can be set or passed through to the container like this:
199
256
 
200
- RakeCompilerDock.sh "rake cross native gem OPENSSL_VERSION=#{ENV['OPENSSL_VERSION']}"
257
+ ```ruby
258
+ RakeCompilerDock.sh "rake cross native gem OPENSSL_VERSION=#{ENV['OPENSSL_VERSION']}"
259
+ ```
201
260
 
202
261
 
203
262
  ## More information
data/Rakefile CHANGED
@@ -6,22 +6,33 @@ require_relative "build/parallel_docker_build"
6
6
 
7
7
  RakeCompilerDock::GemHelper.install_tasks
8
8
 
9
+ DOCKERHUB_USER = ENV['DOCKERHUB_USER'] || "larskanis"
10
+ docker_build_cmd = Shellwords.split(ENV['RCD_DOCKER_BUILD'] || "docker build")
11
+
12
+ platforms = [
13
+ ["x86-mingw32", "i686-w64-mingw32"],
14
+ ["x64-mingw32", "x86_64-w64-mingw32"],
15
+ ["x64-mingw-ucrt", "x86_64-w64-mingw32"],
16
+ ["x86-linux", "i686-redhat-linux"],
17
+ ["x86_64-linux", "x86_64-redhat-linux"],
18
+ ["x86_64-darwin", "x86_64-apple-darwin"],
19
+ ["arm64-darwin", "aarch64-apple-darwin"],
20
+ ["arm-linux", "arm-linux-gnueabihf"],
21
+ ["aarch64-linux", "aarch64-linux-gnu"],
22
+ ]
23
+
9
24
  namespace :build do
10
- platforms = [
11
- ["x86-mingw32", "i686-w64-mingw32"],
12
- ["x64-mingw32", "x86_64-w64-mingw32"],
13
- ["x86-linux", "i686-linux-gnu"],
14
- ["x86_64-linux", "x86_64-linux-gnu"],
15
- ]
25
+
16
26
  platforms.each do |platform, target|
17
27
  sdf = "Dockerfile.mri.#{platform}"
28
+
18
29
  desc "Build image for platform #{platform}"
19
30
  task platform => sdf
20
31
  task sdf do
21
- sh "docker build -t larskanis/rake-compiler-dock-mri-#{platform}:#{RakeCompilerDock::IMAGE_VERSION} -f Dockerfile.mri.#{platform} ."
32
+ sh(*docker_build_cmd, "-t", "#{DOCKERHUB_USER}/rake-compiler-dock-mri-#{platform}:#{RakeCompilerDock::IMAGE_VERSION}", "-f", "Dockerfile.mri.#{platform}", ".")
22
33
  end
23
34
 
24
- df = ERB.new(File.read("Dockerfile.mri.erb")).result(binding)
35
+ df = ERB.new(File.read("Dockerfile.mri.erb"), trim_mode: ">").result(binding)
25
36
  File.write(sdf, df)
26
37
  CLEAN.include(sdf)
27
38
  end
@@ -29,10 +40,13 @@ namespace :build do
29
40
  desc "Build image for JRuby"
30
41
  task :jruby => "Dockerfile.jruby"
31
42
  task "Dockerfile.jruby" do
32
- sh "docker build -t larskanis/rake-compiler-dock-jruby:#{RakeCompilerDock::IMAGE_VERSION} -f Dockerfile.jruby ."
43
+ sh(*docker_build_cmd, "-t", "#{DOCKERHUB_USER}/rake-compiler-dock-jruby:#{RakeCompilerDock::IMAGE_VERSION}", "-f", "Dockerfile.jruby", ".")
33
44
  end
34
45
 
35
- RakeCompilerDock::ParallelDockerBuild.new(platforms.map{|pl, _| "Dockerfile.mri.#{pl}" } + ["Dockerfile.jruby"], workdir: "tmp/docker")
46
+ RakeCompilerDock::ParallelDockerBuild.new(platforms.map{|pl, _| "Dockerfile.mri.#{pl}" } + ["Dockerfile.jruby"], workdir: "tmp/docker", docker_build_cmd: docker_build_cmd)
47
+
48
+ desc "Build images for all MRI platforms in parallel"
49
+ multitask :mri => platforms.map(&:first)
36
50
 
37
51
  desc "Build images for all platforms in parallel"
38
52
  multitask :all => platforms.map(&:first) + ["jruby"]
@@ -40,6 +54,14 @@ end
40
54
 
41
55
  task :build => "build:all"
42
56
 
57
+ namespace :prepare do
58
+ desc "Build cross compiler for x64-mingw-ucrt aka RubyInstaller-3.1+"
59
+ task "mingw64-ucrt" do
60
+ sh(*docker_build_cmd, "-t", "#{DOCKERHUB_USER}/mingw64-ucrt:20.04", ".",
61
+ chdir: "mingw64-ucrt")
62
+ end
63
+ end
64
+
43
65
  desc "Run tests"
44
66
  task :test do
45
67
  sh "ruby -w -W2 -I. -Ilib -e \"#{Dir["test/test_*.rb"].map{|f| "require '#{f}';"}.join}\" -- -v"
@@ -66,3 +88,16 @@ task :update_lists do
66
88
  EOT
67
89
  end
68
90
  end
91
+
92
+ namespace :release do
93
+ desc "push all docker images"
94
+ task :images do
95
+ jimg = "#{DOCKERHUB_USER}/rake-compiler-dock-jruby:#{RakeCompilerDock::IMAGE_VERSION}"
96
+ sh "docker", "push", jimg
97
+
98
+ platforms.each do |platform, _|
99
+ img = "#{DOCKERHUB_USER}/rake-compiler-dock-mri-#{platform}:#{RakeCompilerDock::IMAGE_VERSION}"
100
+ sh "docker", "push", img
101
+ end
102
+ end
103
+ end
@@ -0,0 +1,189 @@
1
+ --- centos7/math.h 2020-12-31 23:15:40.678843646 +0100
2
+ +++ builtin/math.h 2022-03-16 21:35:13.086169875 +0100
3
+ @@ -206,68 +206,142 @@
4
+ FP_NORMAL
5
+ };
6
+
7
+ +
8
+ +/* Depending on the type of TG_ARG, call an appropriately suffixed
9
+ + version of FUNC with arguments (including parentheses) ARGS.
10
+ + Suffixed functions may not exist for long double if it has the same
11
+ + format as double, or for other types with the same format as float,
12
+ + double or long double. The behavior is undefined if the argument
13
+ + does not have a real floating type. The definition may use a
14
+ + conditional expression, so all suffixed versions of FUNC must
15
+ + return the same type (FUNC may include a cast if necessary rather
16
+ + than being a single identifier). */
17
+ +#ifdef __NO_LONG_DOUBLE_MATH
18
+ +# if __HAVE_DISTINCT_FLOAT128
19
+ +# error "Distinct _Float128 without distinct long double not supported."
20
+ +# endif
21
+ +# define __MATH_TG(TG_ARG, FUNC, ARGS) \
22
+ + (sizeof (TG_ARG) == sizeof (float) ? FUNC ## f ARGS : FUNC ARGS)
23
+ +#elif __HAVE_DISTINCT_FLOAT128
24
+ +# if __HAVE_GENERIC_SELECTION
25
+ +# if __HAVE_FLOATN_NOT_TYPEDEF && __HAVE_FLOAT32
26
+ +# define __MATH_TG_F32(FUNC, ARGS) _Float32: FUNC ## f ARGS,
27
+ +# else
28
+ +# define __MATH_TG_F32(FUNC, ARGS)
29
+ +# endif
30
+ +# if __HAVE_FLOATN_NOT_TYPEDEF && __HAVE_FLOAT64X
31
+ +# if __HAVE_FLOAT64X_LONG_DOUBLE
32
+ +# define __MATH_TG_F64X(FUNC, ARGS) _Float64x: FUNC ## l ARGS,
33
+ +# else
34
+ +# define __MATH_TG_F64X(FUNC, ARGS) _Float64x: FUNC ## f128 ARGS,
35
+ +# endif
36
+ +# else
37
+ +# define __MATH_TG_F64X(FUNC, ARGS)
38
+ +# endif
39
+ +# define __MATH_TG(TG_ARG, FUNC, ARGS) \
40
+ + _Generic ((TG_ARG), \
41
+ + float: FUNC ## f ARGS, \
42
+ + __MATH_TG_F32 (FUNC, ARGS) \
43
+ + default: FUNC ARGS, \
44
+ + long double: FUNC ## l ARGS, \
45
+ + __MATH_TG_F64X (FUNC, ARGS) \
46
+ + _Float128: FUNC ## f128 ARGS)
47
+ +# else
48
+ +# if __HAVE_FLOATN_NOT_TYPEDEF
49
+ +# error "Non-typedef _FloatN but no _Generic."
50
+ +# endif
51
+ +# define __MATH_TG(TG_ARG, FUNC, ARGS) \
52
+ + __builtin_choose_expr \
53
+ + (__builtin_types_compatible_p (__typeof (TG_ARG), float), \
54
+ + FUNC ## f ARGS, \
55
+ + __builtin_choose_expr \
56
+ + (__builtin_types_compatible_p (__typeof (TG_ARG), double), \
57
+ + FUNC ARGS, \
58
+ + __builtin_choose_expr \
59
+ + (__builtin_types_compatible_p (__typeof (TG_ARG), long double), \
60
+ + FUNC ## l ARGS, \
61
+ + FUNC ## f128 ARGS)))
62
+ +# endif
63
+ +#else
64
+ +# define __MATH_TG(TG_ARG, FUNC, ARGS) \
65
+ + (sizeof (TG_ARG) == sizeof (float) \
66
+ + ? FUNC ## f ARGS \
67
+ + : sizeof (TG_ARG) == sizeof (double) \
68
+ + ? FUNC ARGS \
69
+ + : FUNC ## l ARGS)
70
+ +#endif
71
+ +
72
+ /* Return number of classification appropriate for X. */
73
+ -# ifdef __NO_LONG_DOUBLE_MATH
74
+ -# define fpclassify(x) \
75
+ - (sizeof (x) == sizeof (float) ? __fpclassifyf (x) : __fpclassify (x))
76
+ -# else
77
+ -# define fpclassify(x) \
78
+ - (sizeof (x) == sizeof (float) \
79
+ - ? __fpclassifyf (x) \
80
+ - : sizeof (x) == sizeof (double) \
81
+ - ? __fpclassify (x) : __fpclassifyl (x))
82
+ +# if ((__GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__) \
83
+ + ) \
84
+ + && (!defined __OPTIMIZE_SIZE__ || defined __cplusplus)
85
+ + /* The check for __cplusplus allows the use of the builtin, even
86
+ + when optimization for size is on. This is provided for
87
+ + libstdc++, only to let its configure test work when it is built
88
+ + with -Os. No further use of this definition of fpclassify is
89
+ + expected in C++ mode, since libstdc++ provides its own version
90
+ + of fpclassify in cmath (which undefines fpclassify). */
91
+ +# define fpclassify(x) __builtin_fpclassify (FP_NAN, FP_INFINITE, \
92
+ + FP_NORMAL, FP_SUBNORMAL, FP_ZERO, x)
93
+ +# else
94
+ +# define fpclassify(x) __MATH_TG ((x), __fpclassify, (x))
95
+ # endif
96
+
97
+ /* Return nonzero value if sign of X is negative. */
98
+ -# ifdef __NO_LONG_DOUBLE_MATH
99
+ -# define signbit(x) \
100
+ - (sizeof (x) == sizeof (float) ? __signbitf (x) : __signbit (x))
101
+ -# else
102
+ -# define signbit(x) \
103
+ - (sizeof (x) == sizeof (float) \
104
+ - ? __signbitf (x) \
105
+ - : sizeof (x) == sizeof (double) \
106
+ - ? __signbit (x) : __signbitl (x))
107
+ +# if __GNUC_PREREQ (6,0)
108
+ +# define signbit(x) __builtin_signbit (x)
109
+ +# elif defined __cplusplus
110
+ + /* In C++ mode, __MATH_TG cannot be used, because it relies on
111
+ + __builtin_types_compatible_p, which is a C-only builtin.
112
+ + The check for __cplusplus allows the use of the builtin instead of
113
+ + __MATH_TG. This is provided for libstdc++, only to let its configure
114
+ + test work. No further use of this definition of signbit is expected
115
+ + in C++ mode, since libstdc++ provides its own version of signbit
116
+ + in cmath (which undefines signbit). */
117
+ +# define signbit(x) __builtin_signbitl (x)
118
+ +# elif __GNUC_PREREQ (4,0)
119
+ +# define signbit(x) __MATH_TG ((x), __builtin_signbit, (x))
120
+ +# else
121
+ +# define signbit(x) __MATH_TG ((x), __signbit, (x))
122
+ # endif
123
+
124
+ /* Return nonzero value if X is not +-Inf or NaN. */
125
+ -# ifdef __NO_LONG_DOUBLE_MATH
126
+ -# define isfinite(x) \
127
+ - (sizeof (x) == sizeof (float) ? __finitef (x) : __finite (x))
128
+ -# else
129
+ -# define isfinite(x) \
130
+ - (sizeof (x) == sizeof (float) \
131
+ - ? __finitef (x) \
132
+ - : sizeof (x) == sizeof (double) \
133
+ - ? __finite (x) : __finitel (x))
134
+ +# if (__GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__)
135
+ +# define isfinite(x) __builtin_isfinite (x)
136
+ +# else
137
+ +# define isfinite(x) __MATH_TG ((x), __finite, (x))
138
+ # endif
139
+
140
+ /* Return nonzero value if X is neither zero, subnormal, Inf, nor NaN. */
141
+ -# define isnormal(x) (fpclassify (x) == FP_NORMAL)
142
+ +# if (__GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__)
143
+ +# define isnormal(x) __builtin_isnormal (x)
144
+ +# else
145
+ +# define isnormal(x) (fpclassify (x) == FP_NORMAL)
146
+ +# endif
147
+
148
+ /* Return nonzero value if X is a NaN. We could use `fpclassify' but
149
+ we already have this functions `__isnan' and it is faster. */
150
+ -# ifdef __NO_LONG_DOUBLE_MATH
151
+ -# define isnan(x) \
152
+ - (sizeof (x) == sizeof (float) ? __isnanf (x) : __isnan (x))
153
+ -# else
154
+ -# define isnan(x) \
155
+ - (sizeof (x) == sizeof (float) \
156
+ - ? __isnanf (x) \
157
+ - : sizeof (x) == sizeof (double) \
158
+ - ? __isnan (x) : __isnanl (x))
159
+ +# if (__GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__)
160
+ +# define isnan(x) __builtin_isnan (x)
161
+ +# else
162
+ +# define isnan(x) __MATH_TG ((x), __isnan, (x))
163
+ # endif
164
+
165
+ /* Return nonzero value if X is positive or negative infinity. */
166
+ -# ifdef __NO_LONG_DOUBLE_MATH
167
+ +# if __HAVE_DISTINCT_FLOAT128 && !__GNUC_PREREQ (7,0) \
168
+ + && !defined __SUPPORT_SNAN__ && !defined __cplusplus
169
+ + /* Since __builtin_isinf_sign is broken for float128 before GCC 7.0,
170
+ + use the helper function, __isinff128, with older compilers. This is
171
+ + only provided for C mode, because in C++ mode, GCC has no support
172
+ + for __builtin_types_compatible_p (and when in C++ mode, this macro is
173
+ + not used anyway, because libstdc++ headers undefine it). */
174
+ # define isinf(x) \
175
+ - (sizeof (x) == sizeof (float) ? __isinff (x) : __isinf (x))
176
+ + (__builtin_types_compatible_p (__typeof (x), _Float128) \
177
+ + ? __isinff128 (x) : __builtin_isinf_sign (x))
178
+ +# elif (__GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__)
179
+ +# define isinf(x) __builtin_isinf_sign (x)
180
+ # else
181
+ -# define isinf(x) \
182
+ - (sizeof (x) == sizeof (float) \
183
+ - ? __isinff (x) \
184
+ - : sizeof (x) == sizeof (double) \
185
+ - ? __isinf (x) : __isinfl (x))
186
+ +# define isinf(x) __MATH_TG ((x), __isinf, (x))
187
+ # endif
188
+
189
+ /* Bitmasks for the math_errhandling macro. */
@@ -6,7 +6,11 @@ module RakeCompilerDock
6
6
  class ParallelDockerBuild
7
7
  include Rake::DSL
8
8
 
9
- def initialize(dockerfiles, workdir: "tmp/docker", inputdir: ".", task_prefix: "common-")
9
+ attr_reader :docker_build_cmd
10
+
11
+ def initialize(dockerfiles, workdir: "tmp/docker", inputdir: ".", task_prefix: "common-",
12
+ docker_build_cmd: %w["docker", "build"])
13
+ @docker_build_cmd = docker_build_cmd
10
14
  FileUtils.mkdir_p(workdir)
11
15
 
12
16
  files = parse_dockerfiles(dockerfiles, inputdir)
@@ -25,7 +29,7 @@ module RakeCompilerDock
25
29
  # "File1"=>[" FROM a\n",
26
30
  # ...
27
31
  def parse_dockerfiles(dockerfiles, inputdir)
28
- files = dockerfiles.map do |fn|
32
+ dockerfiles.map do |fn|
29
33
  [fn, File.read(File.join(inputdir, fn))]
30
34
  end.map do |fn, f|
31
35
  # Split file contant in lines unless line ends with backslash
@@ -96,7 +100,7 @@ module RakeCompilerDock
96
100
  #
97
101
  # The layers will be reused in subsequent builds, even if they run in parallel.
98
102
  def docker_build(filename, workdir)
99
- sh "docker", "build", "-f", File.join(workdir, filename), "."
103
+ sh(*docker_build_cmd, "-f", File.join(workdir, filename), ".")
100
104
  end
101
105
  end
102
106
  end
@@ -11,14 +11,14 @@ index ebe3d8c..a336b73 100755
11
11
 
12
12
  fi
13
13
  diff --git a/io.c b/io.c
14
- index 82c5940538..a8d3661ec8 100644
14
+ index 48592ac51a..2635ac8ec6 100644
15
15
  --- a/io.c
16
16
  +++ b/io.c
17
- @@ -10721,7 +10721,6 @@ nogvl_copy_stream_wait_write(struct copy_stream_struct *stp)
17
+ @@ -11111,6 +11111,7 @@ nogvl_copy_stream_wait_write(struct copy_stream_struct *stp)
18
+ return 0;
18
19
  }
19
20
 
20
- #if defined HAVE_COPY_FILE_RANGE || (defined __linux__ && defined __NR_copy_file_range)
21
- -# define USE_COPY_FILE_RANGE
22
- #endif
23
-
21
+ +#undef USE_COPY_FILE_RANGE
24
22
  #ifdef USE_COPY_FILE_RANGE
23
+
24
+ static ssize_t
@@ -0,0 +1,28 @@
1
+ diff --git a/tasks/bin/cross-ruby.rake b/tasks/bin/cross-ruby.rake
2
+ index 8317a2a..5a1b3ea 100644
3
+ --- a/tasks/bin/cross-ruby.rake
4
+ +++ b/tasks/bin/cross-ruby.rake
5
+ @@ -116,10 +116,22 @@ RUBY_CC_VERSIONS.split(":").each do |ruby_cc_version|
6
+ "--host=#{mingw_host}",
7
+ "--target=#{mingw_target}",
8
+ "--build=#{RUBY_BUILD}",
9
+ - '--enable-shared',
10
+ + '--enable-install-static-library',
11
+ + '--disable-jit-support',
12
+ '--disable-install-doc',
13
+ '--with-ext=',
14
+ ]
15
+ + if mingw_host=~/darwin/
16
+ + options += [
17
+ + '--enable-static',
18
+ + '--disable-shared',
19
+ + ]
20
+ + else
21
+ + options += [
22
+ + '--enable-static',
23
+ + '--enable-shared',
24
+ + ]
25
+ + end
26
+
27
+ # Force Winsock2 for Ruby 1.8, 1.9 defaults to it
28
+ options << "--with-winsock2" if major == "1.8"
data/build/rcd-env.sh ADDED
@@ -0,0 +1,6 @@
1
+ # set up a working RCD build environment
2
+ export RAKE_EXTENSION_TASK_NO_NATIVE=true
3
+ if ! test -e "$HOME"/.rake-compiler ; then
4
+ ln -s /usr/local/rake-compiler "$HOME"/.rake-compiler
5
+ fi
6
+ mkdir -p "$HOME"/.gem
data/build/runas CHANGED
@@ -4,11 +4,4 @@ groupadd -o -g "$GID" "$GROUP"
4
4
  mkdir -p /tmp/home
5
5
  useradd -o -g "$GID" -u "$UID" -G rvm,sudo -p "" -b /tmp/home -m "$USER"
6
6
 
7
- HOME=$(bash <<< "echo ~$USER")
8
- ln -s /usr/local/rake-compiler "$HOME"/.rake-compiler
9
- mkdir -p "$HOME"/.gem
10
- chown "$USER" "$HOME"/.gem
11
-
12
- sudo -u "$USER" --set-home \
13
- BASH_ENV=/etc/rubybashrc \
14
- -- "$@"
7
+ /usr/bin/sudo -u "$USER" -H BASH_ENV=/etc/rubybashrc -- "$@"
data/build/sudoers CHANGED
@@ -1 +1 @@
1
- Defaults env_keep += "http_proxy https_proxy ftp_proxy GEM_PRIVATE_KEY_PASSPHRASE RCD_HOST_RUBY_PLATFORM RCD_HOST_RUBY_VERSION RCD_IMAGE RUBY_CC_VERSION"
1
+ Defaults env_keep += "http_proxy https_proxy ftp_proxy GEM_PRIVATE_KEY_PASSPHRASE RCD_HOST_RUBY_PLATFORM RCD_HOST_RUBY_VERSION RCD_IMAGE RUBY_CC_VERSION LD_LIBRARY_PATH DEVTOOLSET_ROOTPATH"
@@ -41,11 +41,12 @@ module RakeCompilerDock
41
41
  user = options.fetch(:username){ current_user }
42
42
  group = options.fetch(:groupname){ current_group }
43
43
  rubyvm = options.fetch(:rubyvm){ ENV['RCD_RUBYVM'] } || "mri"
44
+ jrubyvm = rubyvm.to_s == "jruby"
44
45
 
45
- platforms = options.fetch(:platform){ ENV['RCD_PLATFORM'] } || "x86-mingw32 x64-mingw32"
46
+ platforms = options.fetch(:platform){ ENV['RCD_PLATFORM'] } || (jrubyvm ? "jruby" : "x86-mingw32 x64-mingw32")
46
47
  platforms.split(" ").each do |platform|
47
48
  image_name = options.fetch(:image) do
48
- platform_postfix = rubyvm.to_s == "jruby" ? "" : "-#{platform}"
49
+ platform_postfix = jrubyvm ? "" : "-#{platform}"
49
50
  ENV['RCD_IMAGE'] ||
50
51
  ENV['RAKE_COMPILER_DOCK_IMAGE'] ||
51
52
  "larskanis/rake-compiler-dock-#{rubyvm}#{platform_postfix}:#{IMAGE_VERSION}"
@@ -1,4 +1,4 @@
1
1
  module RakeCompilerDock
2
- VERSION = "1.0.1"
3
- IMAGE_VERSION = "1.0.0"
2
+ VERSION = "1.2.1"
3
+ IMAGE_VERSION = "1.2.1"
4
4
  end