Skip to content

Do not use private linkage for slice literal buffers#15746

Merged
straight-shoota merged 1 commit intocrystal-lang:masterfrom
HertzDevil:bug/slice-literal-linkage
May 8, 2025
Merged

Do not use private linkage for slice literal buffers#15746
straight-shoota merged 1 commit intocrystal-lang:masterfrom
HertzDevil:bug/slice-literal-linkage

Conversation

@HertzDevil
Copy link
Contributor

@HertzDevil HertzDevil commented May 6, 2025

The following snippet used to fail because a method in Foo's LLVM module refers to a $Slice:* buffer variable defined in the main LLVM module:

module Foo
  def self.foo
    Slice.literal(1)
  end
end

Foo.foo

The correct linkage is now used for the $Slice:* variables.

The existing workaround is to move the literal to a constant, in which case the constant initializer (const_init or const_read) is also defined in the main LLVM module, thus eliminating the link-time failure. But see also #15701.

@HertzDevil HertzDevil added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:lang topic:stdlib:collection experimental labels May 6, 2025
@straight-shoota straight-shoota added this to the 1.17.0 milestone May 6, 2025
@straight-shoota straight-shoota merged commit abd6980 into crystal-lang:master May 8, 2025
38 checks passed
@HertzDevil HertzDevil deleted the bug/slice-literal-linkage branch May 8, 2025 13:31
straight-shoota pushed a commit that referenced this pull request May 26, 2025
Although `StringLiteral#to_utf16` was introduced in 1.13, we assume only 1.16
has complete support for slice literals (and this version number will most
likely be bumped after #15746).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

experimental kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:lang topic:stdlib:collection

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants