Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Link time optimization breaks build: no match insn: amcas_db_d $r12,$r25,$r15 #15

Open
asheplyakov opened this issue Feb 7, 2024 · 3 comments

Comments

@asheplyakov
Copy link

asheplyakov commented Feb 7, 2024

When link time optimization is enabled the code fails to build with a lot of assembler errors like:

{standard input}:607403: Error: no match insn: amcas_d  $r12,$r15,$r16  
{standard input}:611922: Error: no match insn: amcas_db_d       $r12,$r13,$r23
{standard input}:612148: Error: no match insn: amcas_db_d       $r13,$r25,$r14
{standard input}:612188: Error: no match insn: amcas_db_d       $r12,$r25,$r15
{standard input}:614413: Error: no match insn: amcas_d  $r12,$r15,$r18  
{standard input}:621115: Error: no match insn: amcas_d  $r12,$r15,$r18  
{standard input}:622330: Error: no match insn: amcas_db_d       $r12,$r4,$r13
{standard input}:622673: Error: no match insn: amcas_db_d       $r12,$r4,$r13
{standard input}:623031: Error: no match insn: amcas_d  $r12,$r15,$r16  
{standard input}:627166: Error: no match insn: amcas_d  $r12,$r15,$r18  
{standard input}:632288: Error: no match insn: amcas_db_d       $r12,$r13,$r15

The problem is that the compiler is free to reorder (or even eliminate) top-level asm statements,
hence amcas_d macro (defined in src/hotspot/os_cpu/linux_loongarch/amcas_asm.h) might be missing when processing inline assembly in src/hotspot/os_cpu/linux_loongarch/atomic_linux_loongarch.hpp.

To avoid the problem one can include macros definition from inline assembly, i.e. with .include \"amcas_asm.h\", and set proper assembler flags so the assembler can locate amcas_asm.h file (like -Wa,-I -Wa,src/hotspot/os_cpu/linux_loongarch or similar)

@asheplyakov asheplyakov changed the title Compilation fails: Error: no match insn: amcas_db_d $r12,$r25,$r15 Link time optimization breaks build: no match insn: amcas_db_d $r12,$r25,$r15 Feb 7, 2024
vt-alt pushed a commit to altlinux/specs that referenced this issue Feb 7, 2024
- NMU: worked around FTBFS on LoongArch: disabled LTO until the problem
  is solved properly, see loongson/jdk21u#15
@theaoqi
Copy link
Collaborator

theaoqi commented Feb 9, 2024

Hi @asheplyakov, thanks for reporting this issue. We will follow up. It’s the Chinese New Year holiday right now, so it might take some time.

@sunny868
Copy link

@asheplyakov How can I reproduce this problem? What is the compilation environment you are using?

@asheplyakov
Copy link
Author

@asheplyakov How can I reproduce this problem?

Just enable link time optimization:

bash configure --with-extra-cflags='-O2 -flto=auto' --with-extra-cxxflags='-O2 -flto=auto' --with-extra-ldflags='-O2 -flto=auto'
make images

What is the compilation environment you are using?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants