Skip to content

Commit 9a86afd

Browse files
committed
PICORB_ALLOC_ALIGN
1 parent 70ee563 commit 9a86afd

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

mrbgems/picoruby-mruby/mrbgem.rake

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,13 @@ MRuby::Gem::Specification.new('picoruby-mruby') do |spec|
1919
spec.cc.include_paths << "#{build.gems['mruby-compiler2'].dir}/include"
2020
spec.cc.include_paths << "#{build.gems['mruby-compiler2'].dir}/lib/prism/include"
2121

22-
ALIGN = 4 # or 8
22+
# I don't know why but removing this causes a problem
23+
# even if build_config has the same define
24+
spec.cc.defines << "MRB_INT64"
2325

24-
build.cc.defines << "MRB_INT64"
26+
align = build.cc.defines.find{_1.start_with?("PICORB_ALLOC_ALIGN=")}.then do |define|
27+
define&.split("=")&.last || 4
28+
end
2529

2630
if spec.cc.defines.include?("PICORB_ALLOC_O1HEAP")
2731
heap_page_size = o1heap_page_size(13)
@@ -32,7 +36,7 @@ MRuby::Gem::Specification.new('picoruby-mruby') do |spec|
3236

3337
if spec.cc.defines.include?("PICORB_ALLOC_TINYALLOC")
3438
alloc_dir = "#{dir}/lib/tinyalloc"
35-
spec.cc.defines << "TA_ALIGNMENT=#{ALIGN}"
39+
spec.cc.defines << "TA_ALIGNMENT=#{align}"
3640
elsif spec.cc.defines.include?("PICORB_ALLOC_O1HEAP")
3741
alloc_dir = "#{dir}/lib/o1heap/o1heap"
3842
unless File.directory?(alloc_dir)
@@ -51,7 +55,7 @@ MRuby::Gem::Specification.new('picoruby-mruby') do |spec|
5155
spec.cc.defines << "_DEBUG"
5256
end
5357
elsif spec.cc.defines.include?("PICORB_ALLOC_ESTALLOC")
54-
spec.cc.defines << "ESTALLOC_ALIGNMENT=#{ALIGN}"
58+
spec.cc.defines << "ESTALLOC_ALIGNMENT=#{align}"
5559
if spec.cc.defines.any?{ _1.start_with?("PICORUBY_DEBUG") }
5660
spec.cc.defines << "ESTALLOC_DEBUG=1"
5761
end

0 commit comments

Comments
 (0)