rubycc 1.0.0 → 1.1.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.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +61 -0
  3. data/README.md +26 -14
  4. data/data/verified_gems.json +85 -63
  5. data/exe/rubycc-ar +11 -3
  6. data/include/libc/sys/cdefs.h +12 -0
  7. data/lib/rubycc/backend/aarch64.rb +705 -117
  8. data/lib/rubycc/backend/slot_residency.rb +169 -0
  9. data/lib/rubycc/backend/x86_64.rb +924 -137
  10. data/lib/rubycc/command_line.rb +339 -0
  11. data/lib/rubycc/compile_error.rb +6 -3
  12. data/lib/rubycc/compiler.rb +17 -2
  13. data/lib/rubycc/diagnostics.rb +105 -0
  14. data/lib/rubycc/doctor/gemfile.rb +12 -3
  15. data/lib/rubycc/doctor/verified_gems.rb +5 -1
  16. data/lib/rubycc/driver.rb +66 -10
  17. data/lib/rubycc/front/ast.rb +18 -7
  18. data/lib/rubycc/front/constant_evaluator.rb +12 -0
  19. data/lib/rubycc/front/lexeme_reader.rb +3 -1
  20. data/lib/rubycc/front/parser.rb +51 -18
  21. data/lib/rubycc/ir/analysis.rb +82 -0
  22. data/lib/rubycc/ir/call_convention.rb +74 -7
  23. data/lib/rubycc/ir/generator.rb +319 -9
  24. data/lib/rubycc/ir/ir.rb +39 -1
  25. data/lib/rubycc/ir/promotion.rb +255 -0
  26. data/lib/rubycc/ir/simplify.rb +570 -0
  27. data/lib/rubycc/link/library_resolver.rb +17 -5
  28. data/lib/rubycc/link/partial_linker.rb +8 -1
  29. data/lib/rubycc/link/shared_linker.rb +2 -2
  30. data/lib/rubycc/mkmf_shim.rb +178 -12
  31. data/lib/rubycc/objfile/ar_archive.rb +13 -2
  32. data/lib/rubycc/objfile/elf_reader.rb +13 -2
  33. data/lib/rubycc/pkgconf/parser.rb +4 -0
  34. data/lib/rubycc/pkgconf/resolver.rb +3 -1
  35. data/lib/rubycc/pkgconf/system_path_filter.rb +8 -2
  36. data/lib/rubycc/preprocess/preprocessor.rb +161 -37
  37. data/lib/rubycc/preprocess/scanner.rb +69 -14
  38. data/lib/rubycc/preprocess/token_converter.rb +11 -1
  39. data/lib/rubycc/rmake/cli.rb +32 -4
  40. data/lib/rubycc/rmake/executor.rb +157 -226
  41. data/lib/rubycc/rmake/makefile.rb +35 -13
  42. data/lib/rubycc/rmake/parser.rb +8 -2
  43. data/lib/rubycc/rmake/rmake.rb +1 -0
  44. data/lib/rubycc/rmake/tool_command.rb +69 -0
  45. data/lib/rubycc/shell.rb +510 -0
  46. data/lib/rubycc/type.rb +23 -7
  47. data/lib/rubycc/version.rb +1 -1
  48. data/lib/rubycc.rb +12 -0
  49. data/lib/rubygems_plugin.rb +31 -3
  50. metadata +14 -3
@@ -16,8 +16,9 @@
16
16
  # When off, the plugin must be inert — it is loaded on *every* `gem` command, so
17
17
  # the disabled path does no work and touches no state. When on it rewrites four
18
18
  # environment variables the RubyGems build inherits:
19
- # * MAKE -> exe/rmake, which RubyGems runs as `$(MAKE)`; rmake builds the
20
- # generated Makefile with rubycc always substituted for $(CC);
19
+ # * MAKE -> exe/rmake *launched through this Ruby*, which RubyGems runs as
20
+ # `$(MAKE)`; rmake builds the generated Makefile with rubycc
21
+ # always substituted for $(CC);
21
22
  # * PKG_CONFIG -> exe/rubycc-pkgconf, the pkg-config shim;
22
23
  # * RUBYLIB <- gains this gem's lib/ so the extconf child can require rubycc;
23
24
  # * RUBYOPT <- gains `-rrubycc/mkmf_shim` so the extconf child's mkmf issues
@@ -25,6 +26,20 @@
25
26
  # Makefile.
26
27
  # Every rewrite is idempotent: re-running install! adds no duplicate PATH/RUBYOPT
27
28
  # entries and re-assigns the same MAKE/PKG_CONFIG values.
29
+ #
30
+ # `MAKE` names the interpreter explicitly (`<RbConfig.ruby> <path>/exe/rmake`)
31
+ # rather than the executable alone. rmake's shebang is `#!/usr/bin/env ruby`,
32
+ # which the kernel cannot resolve on an image without /usr/bin/env — the minimal
33
+ # environment DESIGN R5 targets, where every exec of it would fail with status
34
+ # 127 — and which would otherwise pick whichever `ruby` PATH happens to lead to
35
+ # rather than the one the gem is being installed into. RubyGems shellsplits
36
+ # `ENV["MAKE"]` (Gem::Ext::Builder.make), so a two-word value is the supported
37
+ # spelling; both words are quoted, since an installation path may contain a
38
+ # space.
39
+ #
40
+ # Everything that spelling needs — rbconfig and rubycc's own splitter — is
41
+ # required inside install!, not at the top of this file: the disabled path must
42
+ # load nothing, and this file is loaded by every `gem` command there is.
28
43
  module Rubycc
29
44
  module GemPlugin
30
45
  # This file lives at lib/rubygems_plugin.rb, so __dir__ is the gem's lib/ and
@@ -60,12 +75,25 @@ module Rubycc
60
75
 
61
76
  # Inject the environment that makes the RubyGems extension build use rubycc.
62
77
  def install!
63
- ENV["MAKE"] = RMAKE_EXE
78
+ ENV["MAKE"] = make_command
79
+ # PKG_CONFIG stays a bare path: mkmf stats the value with find_executable0
80
+ # before running it, so it has to be one file name. The mkmf shim puts the
81
+ # interpreter in front of it when the command is actually spawned.
64
82
  ENV["PKG_CONFIG"] = PKGCONF_EXE
65
83
  prepend_path_entry("RUBYLIB", LIB_DIR)
66
84
  prepend_ruby_require(MKMF_SHIM_FEATURE)
67
85
  end
68
86
 
87
+ # rmake as `$(MAKE)`: this very interpreter, then the script, each word
88
+ # quoted so RubyGems' Shellwords.split (and rmake's own splitter, which sees
89
+ # the value again through `$(MAKE)`) reads back the two paths intact.
90
+ def make_command
91
+ require "rbconfig"
92
+ require_relative "rubycc/command_line"
93
+
94
+ [RbConfig.ruby, RMAKE_EXE].map { |word| Rubycc::CommandLine.quote(word) }.join(" ")
95
+ end
96
+
69
97
  # A PATH lookup that spawns nothing: scan the PATH directories for an
70
98
  # executable file of that name (the same resolution `command -v` performs).
71
99
  def on_path?(name)
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubycc
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - DATE Ken
8
+ autorequire:
8
9
  bindir: exe
9
10
  cert_chain: []
10
- date: 1980-01-02 00:00:00.000000000 Z
11
+ date: 2026-09-12 00:00:00.000000000 Z
11
12
  dependencies: []
12
13
  description: |
13
14
  rubycc builds Ruby C extensions on a machine that has no gcc, no binutils, no make
@@ -133,9 +134,12 @@ files:
133
134
  - include/x86intrin.h
134
135
  - lib/rubycc.rb
135
136
  - lib/rubycc/backend/aarch64.rb
137
+ - lib/rubycc/backend/slot_residency.rb
136
138
  - lib/rubycc/backend/x86_64.rb
139
+ - lib/rubycc/command_line.rb
137
140
  - lib/rubycc/compile_error.rb
138
141
  - lib/rubycc/compiler.rb
142
+ - lib/rubycc/diagnostics.rb
139
143
  - lib/rubycc/doctor.rb
140
144
  - lib/rubycc/doctor/builder.rb
141
145
  - lib/rubycc/doctor/cli.rb
@@ -150,9 +154,12 @@ files:
150
154
  - lib/rubycc/front/lexer.rb
151
155
  - lib/rubycc/front/parser.rb
152
156
  - lib/rubycc/front/token.rb
157
+ - lib/rubycc/ir/analysis.rb
153
158
  - lib/rubycc/ir/call_convention.rb
154
159
  - lib/rubycc/ir/generator.rb
155
160
  - lib/rubycc/ir/ir.rb
161
+ - lib/rubycc/ir/promotion.rb
162
+ - lib/rubycc/ir/simplify.rb
156
163
  - lib/rubycc/link/compat_runtime.rb
157
164
  - lib/rubycc/link/errors.rb
158
165
  - lib/rubycc/link/executable_linker.rb
@@ -186,6 +193,8 @@ files:
186
193
  - lib/rubycc/rmake/model.rb
187
194
  - lib/rubycc/rmake/parser.rb
188
195
  - lib/rubycc/rmake/rmake.rb
196
+ - lib/rubycc/rmake/tool_command.rb
197
+ - lib/rubycc/shell.rb
189
198
  - lib/rubycc/type.rb
190
199
  - lib/rubycc/version.rb
191
200
  - lib/rubygems_plugin.rb
@@ -198,6 +207,7 @@ metadata:
198
207
  bug_tracker_uri: https://github.com/nuna/rubycc/issues
199
208
  documentation_uri: https://github.com/nuna/rubycc/blob/master/README.md
200
209
  rubygems_mfa_required: 'true'
210
+ post_install_message:
201
211
  rdoc_options: []
202
212
  require_paths:
203
213
  - lib
@@ -212,7 +222,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
212
222
  - !ruby/object:Gem::Version
213
223
  version: '0'
214
224
  requirements: []
215
- rubygems_version: 3.6.9
225
+ rubygems_version: 3.5.22
226
+ signing_key:
216
227
  specification_version: 4
217
228
  summary: Almost Pure Ruby C toolchain for building Ruby native extensions without
218
229
  gcc/binutils