RFR: 8344607: Link Time Optimization - basic support for clang

Julian Waters jwaters at openjdk.org
Thu Nov 28 03:07:36 UTC 2024


On Wed, 27 Nov 2024 15:14:10 GMT, Matthias Baesken <mbaesken at openjdk.org> wrote:

> Support the clang toolchain when link time optimization is configured.
> Please note that this is NOT intended to enable lto by default and NOT to fix all possible clang-supporting builds or test issues .
> 
> It works on my Linux x86_64 SUSE 15 test machine with  clang15.0.7, also on macOS with Xcode 13.1 devkit  and Xcode 15.4 .
> 
> To be able to build on macOS with Xcode, I had to deal with one issue.  The lto-link process runs into this error 
> 
> 
> ld: <inline asm>:11:1: symbol 'SpinPause_return' is already defined
> SpinPause_return:        
> ^
> for architecture arm64
> clang: error: linker command failed with exit code 1 (use -v to see invocation)
> 
> 
> Seems that when building with LTO,  the  inline assembler code in SpinPause() is not handled well. In the lto inlining the label  SpinPause_return is generated multiple times and causes an 'already defined' error. This goes away when adding NOINLINE to this function.
> Linux/clang did not show this issue, probably the toolchain there does not have the error.

Linux/clang does not have the error because SpinPause on Linux is implemented entirely in assembler files, which are not affected by LTO. Does clang support gas local labels? If it does, SpinPause_return: can be replaced with 1: and the code that refers to SpinPause_return would instead refer to 1f. I think I'd prefer that to NOINLINE on SpinPause

-------------

PR Comment: https://git.openjdk.org/jdk/pull/22412#issuecomment-2505176287


More information about the build-dev mailing list