rake-compiler-dock 1.1.0 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/.github/workflows/ci.yml +240 -0
  4. data/.gitignore +11 -1
  5. data/Dockerfile.jruby +6 -5
  6. data/Dockerfile.mri.erb +91 -45
  7. data/History.md +34 -1
  8. data/README.md +92 -36
  9. data/Rakefile +39 -12
  10. data/build/math_h.patch +189 -0
  11. data/build/parallel_docker_build.rb +7 -3
  12. data/build/patches/{ruby-2.5.8 → ruby-2.5.9}/no_sendfile.patch +0 -0
  13. data/build/patches/{ruby-3.0.0 → ruby-3.1.0}/no_sendfile.patch +0 -0
  14. data/build/patches2/{rake-compiler-1.1.1 → rake-compiler-1.1.6}/0004-Enable-build-of-static-libruby.patch +3 -4
  15. data/build/rcd-env.sh +6 -0
  16. data/build/runas +1 -9
  17. data/lib/rake_compiler_dock/starter.rb +3 -2
  18. data/lib/rake_compiler_dock/version.rb +2 -2
  19. data/mingw64-ucrt/Dockerfile +62 -0
  20. data/mingw64-ucrt/binutils-mingw-w64-ignore-check-errors.patch +13 -0
  21. data/mingw64-ucrt/gcc-mingw-w64-only-c-c++.patch +13 -0
  22. data/mingw64-ucrt/mingw-w64-enable-ucrt.patch +22 -0
  23. data/rake-compiler-dock.gemspec +2 -2
  24. data/test/env/Dockerfile.alpine +17 -0
  25. data/test/env/Dockerfile.centos +22 -0
  26. data/test/env/Dockerfile.debian +24 -0
  27. data/test/rcd_test/Gemfile +11 -0
  28. data/test/rcd_test/Rakefile +76 -0
  29. data/test/rcd_test/ext/java/RcdTestExtService.java +19 -0
  30. data/test/rcd_test/ext/java/RubyRcdTest.java +16 -0
  31. data/test/rcd_test/ext/mri/extconf.rb +29 -0
  32. data/test/rcd_test/ext/mri/rcd_test_ext.c +51 -0
  33. data/test/rcd_test/ext/mri/rcd_test_ext.h +6 -0
  34. data/test/rcd_test/lib/rcd_test.rb +6 -0
  35. data/test/rcd_test/rcd_test.gemspec +27 -0
  36. data/test/rcd_test/test/test_basic.rb +31 -0
  37. data/test/test_environment_variables.rb +56 -31
  38. data/test/test_parallel_docker_build.rb +19 -6
  39. data.tar.gz.sig +0 -0
  40. metadata +75 -37
  41. metadata.gz.sig +2 -2
  42. data/build/patches2/hoe-3.20.0/0001-Load-encrypted-private-key-using-ENV-GEM_PRIVATE_KEY.patch +0 -32
  43. data/build/patches2/rake-compiler-1.1.1/0001-Fix-determining-of-ruby-versions-in-rake-native-gem.patch +0 -44
  44. data/build/patches2/rake-compiler-1.1.1/0003-Allow-building-of-cross-rubies-in-parallel.patch +0 -214
  45. data/build/patches2/rake-compiler-1.1.1/0005-Don-t-mask-out-build-env-vars-for-cross-ruby.patch +0 -30
  46. data/build/patches2/rake-compiler-1.1.1/0006-Use-RAKE_EXTENSION_TASK_NO_NATIVE-env-var-as-the-def.patch +0 -26
  47. data/build/patches2/ruby-2.7.0/ruby2_keywords.patch +0 -15
  48. data/build/patches2/ruby-3.0.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,19 @@ 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.
91
97
 
92
98
  ### JRuby support
93
99
 
@@ -111,17 +117,19 @@ To build java binary gems interactively, it can be called like this:
111
117
  To make the build process reproducible for other parties, it is recommended to add rake-compiler-dock to your Rakefile.
112
118
  This can be done like this:
113
119
 
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
120
+ ```ruby
121
+ task 'gem:native' do
122
+ require 'rake_compiler_dock'
123
+ sh "bundle package --all" # Avoid repeated downloads of gems by using gem files from the host.
124
+ %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|
125
+ RakeCompilerDock.sh "bundle --local && rake native:#{plat} gem", platform: plat
126
+ end
127
+ RakeCompilerDock.sh "bundle --local && rake java gem", rubyvm: :jruby
128
+ end
129
+ ```
122
130
 
123
131
  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.
132
+ That is once for the jruby gems and 6 times for the specified MRI platforms.
125
133
 
126
134
  ### Run builds in parallel
127
135
 
@@ -133,17 +141,19 @@ Please note, that parallel builds only work reliable, if the specific platform g
133
141
 
134
142
  ```ruby
135
143
  namespace "gem" do
144
+ task 'prepare' do
145
+ require 'rake_compiler_dock'
146
+ require 'io/console'
147
+ sh "bundle package --all"
148
+ sh "cp ~/.gem/gem-*.pem build/gem/ || true"
149
+ ENV["GEM_PRIVATE_KEY_PASSPHRASE"] = STDIN.getpass("Enter passphrase of gem signature key: ")
150
+ end
151
+
136
152
  exttask.cross_platform.each do |plat|
137
- desc "Build the native binary gems"
153
+ desc "Build all native binary gems in parallel"
138
154
  multitask 'native' => plat
139
155
 
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
-
156
+ desc "Build the native gem for #{plat}"
147
157
  task plat => 'prepare' do
148
158
  RakeCompilerDock.sh <<-EOT, platform: plat
149
159
  (cp build/gem/gem-*.pem ~/.gem/ || true) &&
@@ -159,10 +169,54 @@ Please note, that parallel builds only work reliable, if the specific platform g
159
169
 
160
170
  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
171
 
162
- gem 'rake-compiler-dock', '~> 1.0'
172
+ ```ruby
173
+ gem 'rake-compiler-dock', '~> 1.2'
174
+ ```
163
175
 
164
176
  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
177
 
178
+ ### As a CI System Container
179
+
180
+ 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.
181
+
182
+ For example, a Github Actions job might look like this:
183
+
184
+ ``` yaml
185
+ jobs:
186
+ native-gem:
187
+ name: "native-gem"
188
+ runs-on: ubuntu-latest
189
+ container:
190
+ image: "larskanis/rake-compiler-dock-mri-x86_64-linux:1.2.1"
191
+ steps:
192
+ - uses: actions/checkout@v2
193
+ - run: bundle install && bundle exec rake gem:x86_64-linux:rcd
194
+ - uses: actions/upload-artifact@v2
195
+ with:
196
+ name: native-gem
197
+ path: gems
198
+ retention-days: 1
199
+ ```
200
+
201
+ Where the referenced rake task might be defined by:
202
+
203
+ ``` ruby
204
+ cross_platforms = ["x64-mingw32", "x86_64-linux", "x86_64-darwin", "arm64-darwin"]
205
+
206
+ namespace "gem" do
207
+ cross_platforms.each do |platform|
208
+ namespace platform do
209
+ task "rcd" do
210
+ Rake::Task["native:#{platform}"].invoke
211
+ Rake::Task["pkg/#{rcee_precompiled_spec.full_name}-#{Gem::Platform.new(platform)}.gem"].invoke
212
+ end
213
+ end
214
+ end
215
+ end
216
+
217
+ ```
218
+
219
+ For an example of rake tasks that support this style of invocation, visit https://github.com/flavorjones/ruby-c-extensions-explained/tree/main/precompiled
166
220
 
167
221
  ## Environment Variables
168
222
 
@@ -173,7 +227,7 @@ The following variables are recognized by rake-compiler-dock:
173
227
  * `RCD_RUBYVM` - The ruby VM and toolchain to be used.
174
228
  Must be one of `mri`, `jruby`.
175
229
  * `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`.
230
+ 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
231
  It is ignored when `rubyvm` is set to `:jruby`.
178
232
  * `RCD_IMAGE` - The docker image that is downloaded and started.
179
233
  Defaults to "larskanis/rake-compiler-dock:IMAGE_VERSION" with an image version that is determined by the gem version.
@@ -189,7 +243,7 @@ The following variables are provided to the running docker container:
189
243
  * `RCD_HOST_RUBY_PLATFORM` - The `RUBY_PLATFORM` of the host ruby.
190
244
  * `RCD_HOST_RUBY_VERSION` - The `RUBY_VERSION` of the host ruby.
191
245
  * `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.
246
+ 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
247
  * `RCD_MOUNTDIR` - The directory which is mounted into the docker container.
194
248
  Defaults to pwd.
195
249
  * `RCD_WORKDIR` - The working directory within the docker container.
@@ -197,7 +251,9 @@ The following variables are provided to the running docker container:
197
251
 
198
252
  Other environment variables can be set or passed through to the container like this:
199
253
 
200
- RakeCompilerDock.sh "rake cross native gem OPENSSL_VERSION=#{ENV['OPENSSL_VERSION']}"
254
+ ```ruby
255
+ RakeCompilerDock.sh "rake cross native gem OPENSSL_VERSION=#{ENV['OPENSSL_VERSION']}"
256
+ ```
201
257
 
202
258
 
203
259
  ## More information
data/Rakefile CHANGED
@@ -7,26 +7,32 @@ require_relative "build/parallel_docker_build"
7
7
  RakeCompilerDock::GemHelper.install_tasks
8
8
 
9
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
+ ]
10
23
 
11
24
  namespace :build do
12
- platforms = [
13
- ["x86-mingw32", "i686-w64-mingw32"],
14
- ["x64-mingw32", "x86_64-w64-mingw32"],
15
- ["x86-linux", "i686-redhat-linux"],
16
- ["x86_64-linux", "x86_64-redhat-linux"],
17
- ["x86_64-darwin", "x86_64-apple-darwin"],
18
- ["arm64-darwin", "aarch64-apple-darwin"],
19
- ]
25
+
20
26
  platforms.each do |platform, target|
21
27
  sdf = "Dockerfile.mri.#{platform}"
22
28
 
23
29
  desc "Build image for platform #{platform}"
24
30
  task platform => sdf
25
31
  task sdf do
26
- sh "docker build -t #{DOCKERHUB_USER}/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}", ".")
27
33
  end
28
34
 
29
- df = ERB.new(File.read("Dockerfile.mri.erb")).result(binding)
35
+ df = ERB.new(File.read("Dockerfile.mri.erb"), trim_mode: ">").result(binding)
30
36
  File.write(sdf, df)
31
37
  CLEAN.include(sdf)
32
38
  end
@@ -34,10 +40,10 @@ namespace :build do
34
40
  desc "Build image for JRuby"
35
41
  task :jruby => "Dockerfile.jruby"
36
42
  task "Dockerfile.jruby" do
37
- sh "docker build -t #{DOCKERHUB_USER}/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", ".")
38
44
  end
39
45
 
40
- 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)
41
47
 
42
48
  desc "Build images for all MRI platforms in parallel"
43
49
  multitask :mri => platforms.map(&:first)
@@ -48,6 +54,14 @@ end
48
54
 
49
55
  task :build => "build:all"
50
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
+
51
65
  desc "Run tests"
52
66
  task :test do
53
67
  sh "ruby -w -W2 -I. -Ilib -e \"#{Dir["test/test_*.rb"].map{|f| "require '#{f}';"}.join}\" -- -v"
@@ -74,3 +88,16 @@ task :update_lists do
74
88
  EOT
75
89
  end
76
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
@@ -1,8 +1,8 @@
1
1
  diff --git a/tasks/bin/cross-ruby.rake b/tasks/bin/cross-ruby.rake
2
- index 8edf5cd..5d25b82 100644
2
+ index 8317a2a..5a1b3ea 100644
3
3
  --- a/tasks/bin/cross-ruby.rake
4
4
  +++ b/tasks/bin/cross-ruby.rake
5
- @@ -116,11 +116,22 @@ RUBY_CC_VERSIONS.split(":").each do |ruby_cc_version|
5
+ @@ -116,10 +116,22 @@ RUBY_CC_VERSIONS.split(":").each do |ruby_cc_version|
6
6
  "--host=#{mingw_host}",
7
7
  "--target=#{mingw_target}",
8
8
  "--build=#{RUBY_BUILD}",
@@ -11,7 +11,6 @@ index 8edf5cd..5d25b82 100644
11
11
  + '--disable-jit-support',
12
12
  '--disable-install-doc',
13
13
  '--with-ext=',
14
- - 'LDFLAGS=-pipe -s',
15
14
  ]
16
15
  + if mingw_host=~/darwin/
17
16
  + options += [
@@ -24,6 +23,6 @@ index 8edf5cd..5d25b82 100644
24
23
  + '--enable-shared',
25
24
  + ]
26
25
  + end
27
-
26
+
28
27
  # Force Winsock2 for Ruby 1.8, 1.9 defaults to it
29
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,12 +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
- /usr/bin/sudo -u "$USER" -H \
13
- BASH_ENV=/etc/rubybashrc \
14
- RAKE_EXTENSION_TASK_NO_NATIVE=true \
15
- -- "$@"
7
+ /usr/bin/sudo -u "$USER" -H BASH_ENV=/etc/rubybashrc -- "$@"
@@ -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.1.0"
3
- IMAGE_VERSION = "1.1.0"
2
+ VERSION = "1.2.2"
3
+ IMAGE_VERSION = "1.2.2"
4
4
  end
@@ -0,0 +1,62 @@
1
+ FROM ubuntu:20.04
2
+
3
+ ARG DEBIAN_FRONTEND=noninteractive
4
+
5
+ RUN set -ex \
6
+ && sed -i -- 's/# deb-src/deb-src/g' /etc/apt/sources.list \
7
+ && apt-get update \
8
+ && apt-get install -y --no-install-recommends \
9
+ build-essential \
10
+ cdbs \
11
+ devscripts \
12
+ equivs \
13
+ fakeroot \
14
+ pkg-config \
15
+ && apt-get clean \
16
+ && rm -rf /tmp/* /var/tmp/*
17
+
18
+ WORKDIR /build
19
+
20
+ # Download mingw sources
21
+ RUN apt-get source mingw-w64-common && \
22
+ cd mingw-w64-* && \
23
+ mk-build-deps -ir -t "apt-get -o Debug::pkgProblemResolver=yes -y --no-install-recommends"
24
+
25
+ # Patch build for UCRT and build UCRT enabled deb-packages
26
+ ADD mingw-w64-*.patch ./
27
+ RUN cd mingw-w64-* && \
28
+ cat debian/rules && \
29
+ ls ../mingw-w64-*.patch | xargs -n1 patch --verbose -p1 -i && \
30
+ dpkg-buildpackage -b && \
31
+ rm -rf ../*.ddeb ../*i686* `pwd`
32
+
33
+ # Install UCRT enabled deb-packages
34
+ RUN dpkg -i mingw-w64-common_7.0.0-2_all.deb \
35
+ mingw-w64-tools_7.0.0-2_amd64.deb \
36
+ mingw-w64-x86-64-dev_7.0.0-2_all.deb
37
+
38
+ # Download gcc-binutils sources for mingw
39
+ RUN apt-get source binutils-mingw-w64 && \
40
+ cd binutils-mingw-w64-* && \
41
+ mk-build-deps -ir -t "apt-get -o Debug::pkgProblemResolver=yes -y --no-install-recommends"
42
+
43
+ # Build gcc-binutils based on UCRT headers and crt
44
+ ADD binutils-mingw-w64-*.patch ./
45
+ RUN cd binutils-mingw-w64-* && \
46
+ ls ../binutils-mingw-w64-*.patch | xargs -n1 patch --verbose -p1 -i && \
47
+ dpkg-buildpackage -b --jobs=auto && \
48
+ rm -rf ../*.ddeb ../*i686* `pwd`
49
+
50
+ # Download gcc sources for mingw
51
+ RUN apt-get source gcc-mingw-w64 && \
52
+ cd gcc-mingw-w64-* && \
53
+ mk-build-deps -ir -t "apt-get -o Debug::pkgProblemResolver=yes -y --no-install-recommends"
54
+
55
+ # Build gcc (only C and C++) based on UCRT headers and crt
56
+ ADD gcc-mingw-w64-*.patch ./
57
+ RUN cd gcc-mingw-w64-* && \
58
+ ls ../gcc-mingw-w64-*.patch | xargs -n1 patch --verbose -p1 -i && \
59
+ dpkg-buildpackage -b --jobs=auto && \
60
+ rm -rf ../*.ddeb ../*i686* `pwd`
61
+
62
+ RUN ls -l *.deb