Skip to content

Commit 558ce7b

Browse files
authored
Chore: Link i128 constants internally if possible (#15217)
1 parent fe90f27 commit 558ce7b

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/compiler/crystal/codegen/const.cr

+8-4
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,16 @@ class Crystal::CodeGenVisitor
4646
@main_mod.globals.add(@main_llvm_typer.llvm_type(const.value.type), global_name)
4747

4848
type = const.value.type
49-
# TODO: there's an LLVM bug that prevents us from having internal globals of type i128 or u128:
49+
# TODO: LLVM < 9.0.0 has a bug that prevents us from having internal globals of type i128 or u128:
5050
# https://bugs.llvm.org/show_bug.cgi?id=42932
51-
# so we just use global.
52-
if @single_module && !(type.is_a?(IntegerType) && (type.kind.i128? || type.kind.u128?))
51+
# so we just use global in that case.
52+
{% if compare_versions(Crystal::LLVM_VERSION, "9.0.0") < 0 %}
53+
if @single_module && !(type.is_a?(IntegerType) && (type.kind.i128? || type.kind.u128?))
54+
global.linkage = LLVM::Linkage::Internal
55+
end
56+
{% else %}
5357
global.linkage = LLVM::Linkage::Internal if @single_module
54-
end
58+
{% end %}
5559

5660
global
5761
end

0 commit comments

Comments
 (0)