Skip to content

Code that uses a libcall marks internal symbol as exported when making object file #132055

Closed
@gbaraldi

Description

@gbaraldi

This is showing up as JuliaLang/julia#57658 (comment) which is holding up julia being able to compile with LLVM20.

The issue is that a defining a libcall in a module and then having it be used is making the libcall symbol become external

source_filename = "text"
target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-apple-macosx10.14.0-macho"

declare i16 @julia_float_to_half(float)

define internal i16 @__truncsfhf2(float %0) {
  %2 = call i16 @julia_float_to_half(float %0)
  ret i16 %2
}

define hidden swiftcc half @julia_fp(float %0) {
  %2 = fptrunc float %0 to half
  ret half %2
}

@llvm.compiler.used = appending global [1 x ptr] [ptr @__truncsfhf2], section "llvm.metadata"
❯ /Users/gabrielbaraldi/julia9/usr/tools/llc lala.ll -filetype=obj -o llvm20.o
usr/lib/julia on  debug-llvm-20 [?] 
❯ nm llvm20.o
0000000000000000 T ___truncsfhf2
                 U _julia_float_to_half
0000000000000010 T _julia_fp
usr/lib/julia on  debug-llvm-20 [?] 
❯ llc lala.ll -filetype=obj -o llvm19.o
usr/lib/julia on  debug-llvm-20 [?] 
❯ nm llvm19.o
0000000000000000 t ___truncsfhf2
                 U _julia_float_to_half
0000000000000010 T _julia_fp

Not sure if this is an intentional change or not but it's between LLVM 19 and 20

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions