konpeito 0.4.1 → 0.4.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6e006122255b4a6a62dcd3c3ec066b97b9be8e3b3142e4d7c5fc0dd2ccd6b010
4
- data.tar.gz: afb890b5639796f4085af9191493241c9dff65ef9abb67c204884998743bde06
3
+ metadata.gz: 18af8ec6ef271ba48955db2f05fc19b70529a318494bced5fe4e2a83febc3544
4
+ data.tar.gz: 076eb7d785e5bff312c1ec5b8c093c6fc1db034eabe397d5cc1d32d57438e332
5
5
  SHA512:
6
- metadata.gz: e6c22d15f78ad5963d979d7bd528e39e202032e8bf9296c5ee4a2dd2b4627b117b70bafb766b118ea7d2c22e315da7a1db3837b102e2992c81be1fde10114ff6
7
- data.tar.gz: db28cfe4761900dd2acadd218dbef736ec4e1b7f8c0debe02827059f3540f4e654438176f3fd9b9dc3d372a3e0e46188f7d5890d2d37a14856a6d3c106eecc68
6
+ metadata.gz: 30fe2f9fc64bd7c4d4cff705e8a3e46bef719e947efb6d81418ba51e54ccaad89f5cc6e145fb28a5d84960c864abcc4a284cf2868e81da2b161102619cbaae08
7
+ data.tar.gz: 7653068f209f65ae14e1258b0cf17c5b9b3f956a2af006d3af87375eeebc7dcaf694f8384184c8b84e98fedb3485b32ce9374d6cd148ced09bda7e6dbcc228d8
data/CHANGELOG.md CHANGED
@@ -5,6 +5,22 @@ All notable changes to Konpeito will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.4.2] - 2026-03-10
9
+
10
+ ### Fixed
11
+ - **Linux symbol collision**: use `internal` linkage for LLVM callback functions to prevent flat namespace collisions on Linux
12
+ - **NativeClass ptr→VALUE**: add missing `ptr2int` conversion for NativeClass objects passed to CRuby APIs
13
+ - **JSON codegen tests**: skip when vendored yyjson source is unavailable (CI environments)
14
+ - **CI stabilization**: run codegen tests per-file in separate processes to prevent `.so` accumulation crashes
15
+
16
+ ### Added
17
+ - **macOS ARM CI job**: unit tests and codegen tests on `macos-latest` (ARM)
18
+ - **mruby CI job**: build and run verification with `konpeito run --target mruby`
19
+ - **Japanese tutorial**: add mruby backend section (5.5) matching English tutorial
20
+
21
+ ### Changed
22
+ - Update `actions/checkout` v4 → v6, `actions/setup-java` v4 → v5
23
+
8
24
  ## [0.4.1] - 2026-03-09
9
25
 
10
26
  ### Added
data/Rakefile CHANGED
@@ -5,7 +5,34 @@ require "rake/testtask"
5
5
  Rake::TestTask.new(:test) do |t|
6
6
  t.libs << "test"
7
7
  t.libs << "lib"
8
- t.test_files = FileList["test/**/*_test.rb"]
8
+ t.test_files = FileList["test/**/*_test.rb"].exclude("test/codegen/**/*_test.rb")
9
+ end
10
+
11
+ desc "Run codegen tests (each file in a separate process to avoid .so accumulation crashes)"
12
+ task "test:codegen" do
13
+ test_files = FileList["test/codegen/**/*_test.rb"].sort
14
+ failed = []
15
+ test_files.each do |f|
16
+ print "#{File.basename(f, '.rb')} "
17
+ unless system("bundle", "exec", "ruby", "-Ilib:test", f)
18
+ failed << f
19
+ end
20
+ end
21
+ puts
22
+ unless failed.empty?
23
+ abort "#{failed.size}/#{test_files.size} codegen test files failed:\n #{failed.join("\n ")}"
24
+ end
25
+ puts "All #{test_files.size} codegen test files passed."
26
+ end
27
+
28
+ desc "Run all tests (non-codegen + codegen in separate processes)"
29
+ task "test:all" => [:test] do
30
+ # Run codegen tests in a separate process so a crash doesn't kill non-codegen results
31
+ sh "bundle exec rake test:codegen" do |ok, _status|
32
+ unless ok
33
+ warn "Codegen tests failed (possibly due to native extension crash on ruby-head)"
34
+ end
35
+ end
9
36
  end
10
37
 
11
38
  desc "Run conformance tests against Ruby/Native/JVM backends"
@@ -23,4 +50,9 @@ task "conformance:jvm" do
23
50
  ruby "spec/conformance/runner.rb", "--jvm-only"
24
51
  end
25
52
 
53
+ desc "Run CI compilation diagnostics"
54
+ task "test:diagnose" do
55
+ ruby "test/ci_diagnostic.rb"
56
+ end
57
+
26
58
  task default: :test
@@ -277,7 +277,7 @@ module Konpeito
277
277
 
278
278
  # Include extra C files in cache key (they affect the binary)
279
279
  source_dir = File.dirname(File.expand_path(source_file))
280
- extra_c_files = Dir.glob(File.join(source_dir, "*.c")).sort
280
+ extra_c_files = Dir.glob(File.join(source_dir, "*.c"))
281
281
 
282
282
  options_hash = {
283
283
  "inline_rbs" => options[:inline_rbs].to_s,
@@ -2985,6 +2985,9 @@ module Konpeito
2985
2985
  # Convert bool to Ruby true/false
2986
2986
  is_true = @builder.icmp(:ne, value, LLVM::Int8.from_i(0))
2987
2987
  @builder.select(is_true, qtrue, qfalse)
2988
+ when [:native_class, :value]
2989
+ # NativeClass struct pointer to VALUE (i64)
2990
+ @builder.ptr2int(value, LLVM::Int64)
2988
2991
  when [:i64, :double]
2989
2992
  @builder.si2fp(value, LLVM::Double)
2990
2993
  when [:double, :i64]
@@ -4826,6 +4829,7 @@ module Konpeito
4826
4829
  callback_func = @mod.functions.add(callback_name,
4827
4830
  [value_type, value_type, LLVM::Int32, LLVM::Pointer(value_type), value_type],
4828
4831
  value_type)
4832
+ callback_func.linkage = :internal
4829
4833
 
4830
4834
  # Save current builder state
4831
4835
  saved_block = @builder.insert_block
@@ -5221,6 +5225,7 @@ module Konpeito
5221
5225
  # --- Shared lambda_true helper (created once per module) ---
5222
5226
  @lambda_true_func ||= begin
5223
5227
  f = @mod.functions.add("__konpeito_lambda_true", [value_type], value_type)
5228
+ f.linkage = :internal
5224
5229
  bb = f.basic_blocks.append("entry")
5225
5230
  @builder.position_at_end(bb)
5226
5231
  @builder.ret(qtrue)
@@ -5231,6 +5236,7 @@ module Konpeito
5231
5236
  arity_func_name = "__konpeito_proc_arity_#{param_count}"
5232
5237
  arity_func = @mod.functions[arity_func_name] || begin
5233
5238
  f = @mod.functions.add(arity_func_name, [value_type], value_type)
5239
+ f.linkage = :internal
5234
5240
  bb = f.basic_blocks.append("entry")
5235
5241
  @builder.position_at_end(bb)
5236
5242
  arity_ruby = @builder.call(@rb_int2inum, LLVM::Int64.from_i(param_count), "arity_val")
@@ -5560,6 +5566,7 @@ module Konpeito
5560
5566
  callback_func = @mod.functions.add(callback_name,
5561
5567
  [LLVM::Pointer(LLVM::Int8)],
5562
5568
  value_type)
5569
+ callback_func.linkage = :internal
5563
5570
 
5564
5571
  # Save current builder state
5565
5572
  saved_block = @builder.insert_block
@@ -5893,6 +5900,7 @@ module Konpeito
5893
5900
  # VALUE callback(VALUE data) - data is pointer to captures array
5894
5901
  callback_type = LLVM::Type.function([value_type], value_type)
5895
5902
  callback_func = @mod.functions.add(callback_name, [value_type], value_type)
5903
+ callback_func.linkage = :internal
5896
5904
 
5897
5905
  # Save current builder state
5898
5906
  saved_block = @builder.insert_block
@@ -5988,6 +5996,7 @@ module Konpeito
5988
5996
 
5989
5997
  # VALUE callback(VALUE mutex) - mutex is passed as data2
5990
5998
  callback_func = @mod.functions.add(callback_name, [value_type], value_type)
5999
+ callback_func.linkage = :internal
5991
6000
 
5992
6001
  # Save current builder state
5993
6002
  saved_block = @builder.insert_block
@@ -8108,6 +8117,7 @@ module Konpeito
8108
8117
 
8109
8118
  # VALUE func(VALUE data) — data (params[0]) = self or escape array
8110
8119
  callback_func = @mod.functions.add(callback_name, [value_type], value_type)
8120
+ callback_func.linkage = :internal
8111
8121
 
8112
8122
  # Save current builder state
8113
8123
  saved_block = @builder.insert_block
@@ -8227,6 +8237,7 @@ module Konpeito
8227
8237
 
8228
8238
  # VALUE func(VALUE data2, VALUE exception)
8229
8239
  callback_func = @mod.functions.add(callback_name, [value_type, value_type], value_type)
8240
+ callback_func.linkage = :internal
8230
8241
 
8231
8242
  # Save current builder state
8232
8243
  saved_block = @builder.insert_block
@@ -8387,6 +8398,7 @@ module Konpeito
8387
8398
  callback_name = "rescue_handler_gflag_#{counter}"
8388
8399
  # VALUE func(VALUE data2, VALUE exception) — data2 (params[0]) = self or escape array
8389
8400
  callback_func = @mod.functions.add(callback_name, [value_type, value_type], value_type)
8401
+ callback_func.linkage = :internal
8390
8402
 
8391
8403
  saved_block = @builder.insert_block
8392
8404
  saved_vars = @variables.dup
@@ -8524,6 +8536,7 @@ module Konpeito
8524
8536
  def generate_rescue_handler_with_flag_callback(rescue_clauses, counter)
8525
8537
  callback_name = "rescue_handler_flag_#{counter}"
8526
8538
  callback_func = @mod.functions.add(callback_name, [value_type, value_type], value_type)
8539
+ callback_func.linkage = :internal
8527
8540
 
8528
8541
  saved_block = @builder.insert_block
8529
8542
  saved_vars = @variables.dup
@@ -45,6 +45,7 @@ module Konpeito
45
45
  @cross_mruby_dir = cross_mruby_dir
46
46
  @cross_libs_dir = cross_libs_dir
47
47
  @output_file = output_file || default_output_file(target: target)
48
+ normalize_output_extension! if @output_file && target == :native
48
49
  @compile_stats = nil
49
50
  @_resolved_file_count = 0
50
51
  @_specialization_count = 0
@@ -533,6 +534,14 @@ module Konpeito
533
534
  end
534
535
  end
535
536
 
537
+ def normalize_output_extension!
538
+ ext = File.extname(@output_file)
539
+ expected = Platform.shared_lib_extension
540
+ if (ext == ".bundle" || ext == ".so") && ext != expected
541
+ @output_file = @output_file.sub(/#{Regexp.escape(ext)}\z/, expected)
542
+ end
543
+ end
544
+
536
545
  def log(message)
537
546
  puts message if verbose
538
547
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Konpeito
4
- VERSION = "0.4.1"
4
+ VERSION = "0.4.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: konpeito
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yasushi Itoh