> From: Jeremie Courreges-Anglas <[email protected]>
> Date: Fri, 16 Dec 2022 01:43:04 +0100
> 
> On riscv64 LTO fails for some ports with this error:
> 
>   ld: error: linking module flags 'SmallDataLimit': IDs have conflicting 
> values in '<REDACTED>.o' and 'ld-temp.o'
> 
> This is because some objects files are built PIC and others with PIE or
> no PIC at all, and the final link which creates ld-temp.o fails to take
> this into account.  The problem is specific to LTO on riscv64, regular
> ELF linking isn't affected.  This issue has been reported upstream
> recently, with a fix that uses llvm::Module::Min:
> 
>   https://reviews.llvm.org/D131230
> 
> Our llvm version doesn't support llvm::Module::Min so instead of
> backporting all/some parts of:
> 
>   
> https://github.com/llvm/llvm-project/commit/b0343a38a5910e980bb031e4014655d77cd0c162
> 
> I suggest we just replace llvm::Module::Error with llvm::Module::Warning
> here.  Except for the pointless warnings, the end result would hopefully
> be the same: the first (and lowest) value is used, the second value from
> ld-temp.o is ignored.
> 
> This will help me get the same LTO support on riscv64 as on other
> archs.  Ports affected so far: games/arx-libertatis, multimedia/svt-av1,
> net/rrdtool, net/wireshark.  I'm sure the list will get longer.
> 
> ok?

Seems like a reasonable temporary workaround to me.

ok kettenis@

> Index: clang/lib/CodeGen/CodeGenModule.cpp
> ===================================================================
> RCS file: /cvs/src/gnu/llvm/clang/lib/CodeGen/CodeGenModule.cpp,v
> retrieving revision 1.1.1.4
> diff -u -p -r1.1.1.4 CodeGenModule.cpp
> --- clang/lib/CodeGen/CodeGenModule.cpp       17 Dec 2021 12:24:37 -0000      
> 1.1.1.4
> +++ clang/lib/CodeGen/CodeGenModule.cpp       15 Dec 2022 22:35:55 -0000
> @@ -846,7 +846,7 @@ void CodeGenModule::EmitBackendOptionsMe
>      break;
>    case llvm::Triple::riscv32:
>    case llvm::Triple::riscv64:
> -    getModule().addModuleFlag(llvm::Module::Error, "SmallDataLimit",
> +    getModule().addModuleFlag(llvm::Module::Warning, "SmallDataLimit",
>                                CodeGenOpts.SmallDataLimit);
>      break;
>    }
> 
> 
> -- 
> jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE
> 
> 

Reply via email to