rake-compiler-dock 1.5.2 → 1.6.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d7d6132fa4f1d2342d8e1ec3e9f2d7fce839026fc68771e2209169b38a61a6f1
4
- data.tar.gz: 31f46ee396d58464bb0083897d4d3e954605ceed34cd3dbeed72d1459d978201
3
+ metadata.gz: 53dbaea874777b182361051f1c425df03d7223cde61a63bb60d6284593c0e273
4
+ data.tar.gz: a389f202249d9ee8415c5adc010030b6c6b026ed8127a77520c5f1b1f5a7831a
5
5
  SHA512:
6
- metadata.gz: 22fe8a19f48c24d2ad0044b59ffdf5e5841d48aacbb8fb0f582be550ace9b2dc27e6b34df93638ff6024c59df172a8857a844f3c40a072a213e1d045c02e8127
7
- data.tar.gz: dca8f2e0b2e18537a0f0c7eda39ff460c9470d60b0e7f19ac3108b58bb06119682f5cfc783563bf6b534ef12c159d2e9e62e38978dba415cb1f2d8580441097f
6
+ metadata.gz: 3f3397f9b5db932ae5a9370d80af39a30475ede7053049e4dd8aec035da1fe1e82d79a38127ea3d0232666ac1965927cc92fb1d03161754d93663ca5ccadf645
7
+ data.tar.gz: 02f7cedfbbcc5e13f51f9f428d4fade38de5bf6032dd28d3f1717a0f1315d8afee2d4bb6f92715bb609f165e2093d9469219db086b0842cdaffe7c81d3851eeb
@@ -382,21 +382,27 @@ jobs:
382
382
  matrix:
383
383
  include:
384
384
  - from_image: amd64/centos
385
+ image_platform: linux/amd64
385
386
  platform: x86_64-linux # centos-8 ships ruby 2.5, rubygems won't recognize -gnu suffix
386
387
  dockerfile: centos
387
388
  - from_image: navikey/raspbian-bullseye
389
+ image_platform: linux/arm/v7
388
390
  platform: arm-linux # bullseye ships ruby 2.7, rubygems won't recognize -gnu suffix
389
391
  dockerfile: debian
390
392
  - from_image: arm64v8/ubuntu
393
+ image_platform: linux/aarch64
391
394
  platform: aarch64-linux # arm64v8 ships ruby 3.0, rubygems won't recognize -gnu suffix
392
395
  dockerfile: debian
393
396
  - from_image: i386/alpine
397
+ image_platform: linux/386
394
398
  platform: x86-linux-musl
395
399
  dockerfile: alpine
396
400
  - from_image: arm32v6/alpine
401
+ image_platform: linux/arm/v6
397
402
  platform: arm-linux-musl
398
403
  dockerfile: alpine
399
404
  - from_image: alpine
405
+ image_platform: linux/amd64
400
406
  platform: x86_64-linux-musl
401
407
  dockerfile: alpine
402
408
  runs-on: ubuntu-latest
@@ -409,6 +415,6 @@ jobs:
409
415
  - name: Build ${{ matrix.from_image }} image
410
416
  run: |
411
417
  docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
412
- docker build --rm --build-arg from_image=${{ matrix.from_image }} -t ruby-test -f test/env/Dockerfile.${{ matrix.dockerfile }} .
418
+ docker build --rm --build-arg from_image=${{ matrix.from_image }} --platform=${{ matrix.image_platform }} -t ruby-test -f test/env/Dockerfile.${{ matrix.dockerfile }} .
413
419
  - name: Run tests
414
420
  run: docker run --rm -t --network=host -v `pwd`:/build ruby-test
@@ -41,7 +41,8 @@ jobs:
41
41
  with:
42
42
  ruby-version: "3.1"
43
43
  bundler-cache: true
44
- - id: rcd_config
44
+ - name: Generate docker image names
45
+ id: rcd_config
45
46
  run: |
46
47
  bundle exec ruby -e ' \
47
48
  require "rake_compiler_dock"; \
@@ -49,8 +50,11 @@ jobs:
49
50
  puts RakeCompilerDock::Starter.container_image_name(:platform => %q(${{matrix.platform}})); \
50
51
  print "snapshot_name="; \
51
52
  puts RakeCompilerDock::Starter.container_image_name(:platform => %q(${{matrix.platform}}), :version => %q(snapshot)); \
53
+ if %q(${{matrix.platform}}).end_with?("-gnu"); \
54
+ print "generic_linux_snapshot_name="; \
55
+ puts RakeCompilerDock::Starter.container_image_name(:platform => %q(${{matrix.platform}}), :version => %q(snapshot)).chomp("-gnu"); \
56
+ end \
52
57
  ' | tee -a $GITHUB_OUTPUT
53
-
54
58
  - name: Build docker image
55
59
  env:
56
60
  RCD_DOCKER_BUILD: docker buildx build --cache-from=type=local,src=tmp/build-cache --cache-to=type=local,dest=tmp/build-cache-new --load
@@ -65,7 +69,13 @@ jobs:
65
69
  registry: ghcr.io
66
70
  username: ${{github.actor}}
67
71
  password: ${{secrets.GITHUB_TOKEN}}
68
- - run: |
72
+ - name: Push the docker image
73
+ run: |
69
74
  docker images
70
75
  docker tag ${{steps.rcd_config.outputs.image_name}} ${{steps.rcd_config.outputs.snapshot_name}}
71
76
  docker push ${{steps.rcd_config.outputs.snapshot_name}}
77
+ - name: Push a generic linux image
78
+ if: ${{ steps.rcd_config.outputs.generic_linux_snapshot_name }}
79
+ run: |
80
+ docker tag ${{steps.rcd_config.outputs.image_name}} ${{steps.rcd_config.outputs.generic_linux_snapshot_name}}
81
+ docker push ${{steps.rcd_config.outputs.generic_linux_snapshot_name}}
data/Dockerfile.mri.erb CHANGED
@@ -1,32 +1,14 @@
1
- <%
2
- image = case platform
3
- when /x86_64-linux-gnu/ then "quay.io/pypa/manylinux2014_x86_64:latest@sha256:04bffb03cd21d7945c327f67745897adddeb1d6635d79ba98811e7526460f2e0"
4
- when /x86-linux-gnu/ then "quay.io/pypa/manylinux2014_i686:latest@sha256:516a28921cf4d2544be8278764e3e5d33da0a4b4e26bbbb523a5702b96b329b0"
5
- else "docker.io/library/ubuntu:20.04@sha256:80ef4a44043dec4490506e6cc4289eeda2d106a70148b74b5ae91ee670e9c35d"
6
- end
7
- manylinux = !!(image =~ /manylinux/)
8
- %>
1
+ <% image = "ubuntu:20.04" %>
9
2
  FROM <%= image %>
10
3
 
11
4
  ##
12
5
  ## Install required base packages for compiling ruby
13
6
  ##
14
- <% if manylinux %>
15
- RUN yum install -y sudo ruby less git wget curl autoconf libtool cmake gcc-c++ xz readline-devel sqlite-devel openssl-devel libffi-devel libyaml-devel
16
-
17
- ## Prepare sudo
18
- RUN rm -f /usr/local/bin/sudo && \
19
- groupadd -r sudo && \
20
- echo "%sudo ALL=(ALL) ALL" >> /etc/sudoers
21
-
22
- <% else %>
23
- ENV DEBIAN_FRONTEND noninteractive
7
+ ENV DEBIAN_FRONTEND=noninteractive
24
8
  RUN apt-get -y update && \
25
9
  apt-get install -y sudo wget curl git-core build-essential xz-utils unzip dirmngr && \
26
10
  apt-get install -y autoconf cmake pkg-config zlib1g-dev libreadline-dev libsqlite0-dev libssl-dev libyaml-dev libffi-dev && \
27
11
  rm -rf /var/lib/apt/lists/*
28
- <% end %>
29
-
30
12
 
31
13
  ##
32
14
  ## install rbenv and ruby-build
@@ -68,23 +50,18 @@ RUN dpkg -i /debs/*.deb
68
50
  COPY build/mk_musl_cross.sh /tmp
69
51
  RUN /tmp/mk_musl_cross.sh <%= target %>
70
52
 
71
- <% elsif !manylinux %>
53
+ <% else %>
72
54
  RUN apt-get -y update && \
73
55
  apt-get install -y <%
74
- if platform =~ /darwin/ %> clang python lzma-dev libxml2-dev libssl-dev libc++-10-dev <% end %><%
56
+ if platform =~ /darwin/ %> clang python lzma-dev libxml2-dev libssl-dev libc++-10-dev <% end %><%
75
57
  if platform =~ /aarch64-linux-gnu/ %> gcc-aarch64-linux-gnu g++-aarch64-linux-gnu <% end %><%
76
58
  if platform =~ /arm-linux-gnu/ %> gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf <% end %><%
77
- if platform =~ /x86-mingw32/ %> gcc-mingw-w64-i686 g++-mingw-w64-i686 <% end %><%
78
- if platform =~ /x64-mingw32/ %> gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64 <% end %> && \
59
+ if platform =~ /x86-linux-gnu/ %> gcc-i686-linux-gnu g++-i686-linux-gnu <% end %><%
60
+ if platform =~ /x86-mingw32/ %> gcc-mingw-w64-i686 g++-mingw-w64-i686 <% end %><%
61
+ if platform =~ /x64-mingw32/ %> gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64 <% end %> && \
79
62
  rm -rf /var/lib/apt/lists/*
80
63
  <% end %>
81
64
 
82
- <% if manylinux %>
83
- # Create dev tools x86-linux-*
84
- COPY build/mk_i686.rb /root/
85
- RUN /root/mk_i686.rb
86
- <% end %>
87
-
88
65
  <% if platform =~ /darwin/ %>
89
66
  COPY build/mk_osxcross.sh /tmp
90
67
  RUN /tmp/mk_osxcross.sh
@@ -133,7 +110,7 @@ RUN sudo mkdir -p /usr/local/rake-compiler && \
133
110
  xrubies_build_plan = if platform =~ /x64-mingw-ucrt/
134
111
  [
135
112
  # Rubyinstaller-3.1.0+ is platform x64-mingw-ucrt
136
- ["3.3.0-rc1:3.2.0:3.1.0", "3.1.3"],
113
+ ["3.3.5:3.2.0:3.1.0", "3.1.3"],
137
114
  ]
138
115
  elsif platform =~ /x64-mingw32/
139
116
  [
@@ -144,7 +121,7 @@ elsif platform =~ /x64-mingw32/
144
121
  else
145
122
  [
146
123
  ["2.6.0:2.5.0:2.4.0", "2.5.9"],
147
- ["3.3.0-rc1:3.2.0:3.1.0:3.0.0:2.7.0", "3.1.3"],
124
+ ["3.3.5:3.2.0:3.1.0:3.0.0:2.7.0", "3.1.3"],
148
125
  ]
149
126
  end
150
127
 
@@ -171,7 +148,7 @@ RUN bash -c " \
171
148
  RUN find /usr/local/rake-compiler/ruby/*linux*/ -name libruby.so | xargs rm
172
149
  RUN find /usr/local/rake-compiler/ruby/*linux*/ -name libruby-static.a | while read f ; do cp $f `echo $f | sed s/-static//` ; done
173
150
  RUN find /usr/local/rake-compiler/ruby/*linux*/ -name libruby.a | while read f ; do ar t $f | xargs ar d $f ; done
174
- RUN find /usr/local/rake-compiler/ruby/*linux*/ -name mkmf.rb | while read f ; do sed -i ':a;N;$!ba;s/TRY_LINK = [^\n]*\n[^\n]*\n[^\n]*LOCAL_LIBS)/& -lruby-static -lpthread -lrt -ldl <% if platform =~ /x86/ %> -lcrypt <% end %>/' $f ; done
151
+ RUN find /usr/local/rake-compiler/ruby/*linux*/ -name mkmf.rb | while read f ; do sed -i ':a;N;$!ba;s/TRY_LINK = [^\n]*\n[^\n]*\n[^\n]*LOCAL_LIBS)/& -lruby-static -lpthread -lrt -ldl <% if platform =~ /x86_64/ %> -lcrypt <% if platform !~ /musl/ %> -lz <% end %> <% end %>/' $f ; done
175
152
  <% end %>
176
153
 
177
154
  <% if platform =~ /mingw/ %>
@@ -221,24 +198,6 @@ RUN mv /opt/osxcross/target/bin/<%= target %>-strip /opt/osxcross/target/bin/<%=
221
198
  ln /root/strip_wrapper_codesign /opt/osxcross/target/bin/<%= target %>-strip
222
199
  <% end %>
223
200
 
224
- <% if manylinux %>
225
- # Enable modern compiler toolset of manylinux image
226
- RUN echo "export PATH=\$DEVTOOLSET_ROOTPATH/usr/bin:\$PATH" >> /etc/rubybashrc
227
-
228
- # Add prefixed versions of compiler tools
229
- RUN for f in addr2line gcc gcov-tool ranlib ar dwp gcc-ranlib nm readelf as elfedit gcc-ar gprof objcopy size c++filt g++ gcov ld objdump strings cpp gcc-nm strip ; do ln -sf $DEVTOOLSET_ROOTPATH/usr/bin/$f $DEVTOOLSET_ROOTPATH/usr/bin/<%= target %>-$f ; done
230
-
231
- # Use builtin functions of newer gcc to avoid linker issues on Musl based Linux
232
- # TODO: remove in v1.6.0 once musl builds have been out for full minor release cycle, see 864be5b2
233
- COPY build/math_h.patch /root/
234
- RUN cd /usr/include/ && \
235
- patch -p1 < /root/math_h.patch
236
-
237
- # Update pkg-config because the distro ships 0.27.1 which is old and has bugs and performance issues.
238
- COPY build/mk_pkg_config.sh /root/
239
- RUN /root/mk_pkg_config.sh
240
- <% end %>
241
-
242
201
  <% if platform =~ /arm64-darwin/ %>
243
202
  # Add a arm64 darwin target as alternative to aarch64
244
203
  RUN grep -E 'rbconfig-aarch64-darwin' /usr/local/rake-compiler/config.yml | sed 's/rbconfig-[a-z0-9_]*-darwin/rbconfig-<%= platform %>/' >> /usr/local/rake-compiler/config.yml
@@ -258,6 +217,6 @@ COPY build/sudoers /etc/sudoers.d/rake-compiler-dock
258
217
 
259
218
  RUN bash -c "rbenv global 3.1.3"
260
219
 
261
- ENV RUBY_CC_VERSION 3.3.0:3.2.0:3.1.0:3.0.0:2.7.0:2.6.0:2.5.0:2.4.0
220
+ ENV RUBY_CC_VERSION=3.3.5:3.2.0:3.1.0:3.0.0:2.7.0:2.6.0:2.5.0:2.4.0
262
221
 
263
222
  CMD bash
data/History.md CHANGED
@@ -1,5 +1,33 @@
1
1
  # `rake-compiler/rake-compiler-dock` Changelog
2
2
 
3
+ ## v1.6.0 / 2024-12-13
4
+
5
+ ### Notable changes
6
+
7
+ #### Standardizing all Linux build images on Ubuntu
8
+
9
+ In this release, we upgraded the base image for the `x86_64-linux-gnu` and `x86-linux-gnu` images from `manylinux2014` to `ubuntu:20.04`. (`manylinux2014` reached end-of-life earlier this year.) As a result, all of the build images are using the same base image, simplifying things considerably. (#122, #126) @flavorjones
10
+
11
+ ⚠ **Note** there are two important changes due to this upgrade:
12
+
13
+ 1. The minimum supported version of GLIBC for the `x86*-linux-gnu` images has increased from 2.17 to 2.29 for `x86_64` and `x86` architectures. (Note that GLIBC was already pinned to 2.29 for ARM architectures.)
14
+ 2. Precompiled gems built with the `x86*linux-gnu` images are less likely to be compatible with Musl systems, and may segfault.
15
+
16
+ For (2) above, if you have been shipping a single `x86_64-linux` native gem for both GNU and Musl systems, **please make sure you test your gems on a Musl system before shipping them**. See the [actions workflow in flavorjones/ruby-c-extensions-explained](https://github.com/flavorjones/ruby-c-extensions-explained/blob/6619a0d94e627897838a79144704387db65a03bc/.github/workflows/precompiled.yml#L137) for an example of how to do this rigorously.
17
+
18
+
19
+ ### Ruby 3.3 support upgraded to `3.3.5`
20
+
21
+ Update Ruby 3.3 support from 3.3.0-rc1 to 3.3.5. Note that the 3.3.x releases are not usable until 3.3.5 because of https://bugs.ruby-lang.org/issues/20088.
22
+
23
+ ⚠ **Note** that if you were specifying `3.3.0` in your `RUBY_CC_VERSION` environment variable, that string will must be updated to `3.3.5`.
24
+
25
+
26
+ ### Added
27
+
28
+ - Add support for the `SOURCE_DATE_EPOCH` environment variable, which can be used to create reproducible builds. (#128) @segiddins
29
+
30
+
3
31
  ## 1.5.2 / 2024-07-30
4
32
 
5
33
  With CentOS 7 becoming EOL as of 2024-06-30, `yum` will no longer work in the `x86_64-linux-gnu` and
data/Rakefile CHANGED
@@ -17,11 +17,11 @@ platforms = [
17
17
  ["arm64-darwin", "aarch64-apple-darwin"],
18
18
  ["x64-mingw-ucrt", "x86_64-w64-mingw32"],
19
19
  ["x64-mingw32", "x86_64-w64-mingw32"],
20
- ["x86-linux-gnu", "i686-redhat-linux-gnu"],
20
+ ["x86-linux-gnu", "i686-linux-gnu"],
21
21
  ["x86-linux-musl", "i686-unknown-linux-musl"],
22
22
  ["x86-mingw32", "i686-w64-mingw32"],
23
23
  ["x86_64-darwin", "x86_64-apple-darwin"],
24
- ["x86_64-linux-gnu", "x86_64-redhat-linux-gnu"],
24
+ ["x86_64-linux-gnu", "x86_64-linux-gnu"],
25
25
  ["x86_64-linux-musl", "x86_64-unknown-linux-musl"],
26
26
  ]
27
27
 
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 LD_LIBRARY_PATH DEVTOOLSET_ROOTPATH"
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 SOURCE_DATE_EPOCH"
@@ -66,6 +66,7 @@ module RakeCompilerDock
66
66
  "-e", "USER=#{user}",
67
67
  "-e", "GROUP=#{group}",
68
68
  "-e", "GEM_PRIVATE_KEY_PASSPHRASE",
69
+ "-e", "SOURCE_DATE_EPOCH",
69
70
  "-e", "ftp_proxy",
70
71
  "-e", "http_proxy",
71
72
  "-e", "https_proxy",
@@ -1,4 +1,4 @@
1
1
  module RakeCompilerDock
2
- VERSION = "1.5.2"
3
- IMAGE_VERSION = "1.5.2"
2
+ VERSION = "1.6.0"
3
+ IMAGE_VERSION = "1.6.0"
4
4
  end
@@ -32,7 +32,7 @@ class TestEnvironmentVariables
32
32
  unless IS_JRUBY
33
33
  def test_RUBY_CC_VERSION
34
34
  df = File.read(File.expand_path("../../Dockerfile.mri.erb", __FILE__))
35
- df =~ /^ENV RUBY_CC_VERSION\s+(.*)\s+$/
35
+ df =~ /^ENV RUBY_CC_VERSION=(.*)$/
36
36
  assert_equal $1, rcd_env['RUBY_CC_VERSION']
37
37
  end
38
38
 
@@ -75,6 +75,12 @@ class TestEnvironmentVariables
75
75
  def test_PWD
76
76
  assert_equal Dir.pwd, rcd_env['PWD']
77
77
  end
78
+
79
+ def test_SOURCE_DATE_EPOCH
80
+ cmd = "SOURCE_DATE_EPOCH=1234567890 " + invocation("echo \$SOURCE_DATE_EPOCH")
81
+ sde = %x(#{cmd}).strip
82
+ assert_equal "1234567890", sde
83
+ end
78
84
  end
79
85
 
80
86
  class AsIfContinuousIntegration < Test::Unit::TestCase
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rake-compiler-dock
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.2
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lars Kanis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-07-30 00:00:00.000000000 Z
11
+ date: 2024-12-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -82,7 +82,6 @@ files:
82
82
  - Rakefile
83
83
  - bin/rake-compiler-dock
84
84
  - build/gem_helper.rb
85
- - build/math_h.patch
86
85
  - build/mk_i686.rb
87
86
  - build/mk_musl_cross.sh
88
87
  - build/mk_osxcross.sh
@@ -141,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
141
140
  - !ruby/object:Gem::Version
142
141
  version: '0'
143
142
  requirements: []
144
- rubygems_version: 3.5.11
143
+ rubygems_version: 3.3.22
145
144
  signing_key:
146
145
  specification_version: 4
147
146
  summary: Easy to use and reliable cross compiler environment for building Windows
data/build/math_h.patch DELETED
@@ -1,189 +0,0 @@
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. */