-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set linkage of
__crystal_*
funs to internal (#15439)
Unlike the usual `fun` for which we might expect to have external linkage, the `__crystal_*` funs are an internal implementation detail to abstract calls to stdlib from the codegen pass (e.g. `__crystal_once`, `__crystal_raise`, ...). When compiling to a single module, we can mark them to have internal linkage, so they're only considered inside the object file. We already do that for all globals and `def`.
- Loading branch information
1 parent
cb7782d
commit ade1e6f
Showing
4 changed files
with
32 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
require "../../spec_helper" | ||
|
||
describe "Codegen: fun" do | ||
it "sets external linkage by default" do | ||
mod = codegen(<<-CRYSTAL, inject_primitives: false, single_module: false) | ||
fun foo; end | ||
fun __crystal_foo; end | ||
CRYSTAL | ||
mod.functions["foo"].linkage.should eq(LLVM::Linkage::External) | ||
mod.functions["__crystal_foo"].linkage.should eq(LLVM::Linkage::External) | ||
end | ||
|
||
it "sets internal linkage to __crystal_ funs when compiling to single module" do | ||
mod = codegen(<<-CRYSTAL, inject_primitives: false, single_module: true) | ||
fun foo; end | ||
fun __crystal_foo; end | ||
CRYSTAL | ||
mod.functions["foo"].linkage.should eq(LLVM::Linkage::External) | ||
mod.functions["__crystal_foo"].linkage.should eq(LLVM::Linkage::Internal) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters