[llvm] r185882 - Don't run internalize if we're outputing bit-code and not an object file.

Bill Wendling isanbard at gmail.com
Thu Aug 8 16:53:26 PDT 2013


On Aug 8, 2013, at 10:06 AM, Rafael EspĂ­ndola <rafael.espindola at gmail.com> wrote:

> On 8 August 2013 12:46, Rafael EspĂ­ndola <rafael.espindola at gmail.com> wrote:
>>> I don't understand: how does output format affect symbol visibility?
>> 
>> 
>> I agree.
>> This looks like a bug in the linker. It should be marking every symbol
>> as needed with -r, in which case internalize is a nop.
> 
> In fact, with your patch reverted and gold I get:
> 
> ---------------
> $ llvm-dis test.o  -o -
> ; ModuleID = 'test.o'
> target datalayout =
> "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
> target triple = "x86_64-unknown-linux-gnu"
> 
> @a = global i32 42, align 4
> $ llvm-dis test2.o  -o -
> ; ModuleID = 'test2.o'
> target datalayout =
> "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
> target triple = "x86_64-unknown-linux-gnu"
> 
> @b = hidden global i32 42, align 4
> $ ~/inst/bin/ld -plugin /home/espindola/llvm/build/lib/LLVMgold.so
> test.o test2.o -plugin-opt emit-llvm -o test3.o -r
> $ llvm-dis test3.o  -o -
> ; ModuleID = 'test3.o'
> target datalayout =
> "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
> target triple = "x86_64-unknown-linux-gnu"
> 
> @a = global i32 42, align 4
> @b = hidden global i32 42, align 4
> $ ~/inst/bin/ld -plugin /home/espindola/llvm/build/lib/LLVMgold.so
> test.o test2.o -plugin-opt emit-llvm -o test3.o -shared
> $ llvm-dis test3.o  -o -
> ; ModuleID = 'test3.o'
> target datalayout =
> "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
> target triple = "x86_64-unknown-linux-gnu"
> 
> @a = global i32 42, align 4
> @b = internal hidden global i32 42, align 4
> ---------------
> 
> Note how with -r @b is hidden, but with -shared it is internal. It is
> an unfortunate regression that the symbols in the .bc file no longer
> match what we get in the final object. Could you please revert this
> and fix it on the linker?
> 
Okay. I reverted it for now.

Nick, Do you have an opinion on whether this is a linker issue?

-bw






More information about the llvm-commits mailing list