[PATCH] Call sys::fs::remove for options::OT_DISABLE

H.J. Lu hjl.tools at gmail.com
Thu Feb 12 06:25:04 PST 2015


On Thu, Feb 12, 2015 at 6:15 AM, Rafael EspĂ­ndola
<rafael.espindola at gmail.com> wrote:
> I assume this shows up with bfd ld.
>
> Is this already covered by some test when run with bfd ld instead of gold?

test/tools/gold/emit-llvm.ll has

; RUN: rm -f %t4.o
; RUN: ld -plugin %llvmshlibdir/LLVMgold.so \
; RUN:     -m elf_x86_64 --plugin-opt=disable-output \
; RUN:    -shared %t.o -o %t4.o
; RUN: not test -a %t4.o

It fails with ld.

> Thanks,
> Rafael
>
>
> On 12 February 2015 at 08:29, H.J. Lu <hjl.tools at gmail.com> wrote:
>> Gold plugin calls exit(0) for options::OT_DISABLE to avoid generating
>> output.  But it isn't very reliable.  This patch calls sys::fs::remove
>> directly to remove output.
>>
>> H.J.
>> ---
>>  tools/gold/gold-plugin.cpp | 5 ++++-
>>  1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/tools/gold/gold-plugin.cpp b/tools/gold/gold-plugin.cpp
>> index dd6d47f..a068c22 100644
>> --- a/tools/gold/gold-plugin.cpp
>> +++ b/tools/gold/gold-plugin.cpp
>> @@ -869,8 +869,11 @@ static ld_plugin_status all_symbols_read_hook(void) {
>>    llvm_shutdown();
>>
>>    if (options::TheOutputType == options::OT_BC_ONLY ||
>> -      options::TheOutputType == options::OT_DISABLE)
>> +      options::TheOutputType == options::OT_DISABLE) {
>> +    if (options::TheOutputType == options::OT_DISABLE)
>> +      sys::fs::remove(output_name);
>>      exit(0);
>> +  }
>>
>>    return Ret;
>>  }
>> --
>> 2.1.0
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits



-- 
H.J.




More information about the llvm-commits mailing list