This is an archive of the discontinued LLVM Phabricator instance.

MIPS: fix build from IR files, nan2008 and FpAbi
ClosedPublic

Authored by wzssyqa on Dec 18 2022, 8:30 AM.

Details

Summary

When we use llc or lld to compiler IR files, the features +nan2008 and +fpxx/+fp64 are not used.
Thus wrong format files are produced.

In IR files, the attributes are only set for function while not the whole compile units.
So we extract the attributes from the first function and use it for the whole unit.

isFPXXDefault: for o32, the FPXX should always be the default, no matter about the vendors.
Of course some distributions with FP64 default enabled should be listed explicit.
Let's add them in future if we know about one.

Diff Detail

Event Timeline

wzssyqa created this revision.Dec 18 2022, 8:30 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 18 2022, 8:30 AM
wzssyqa requested review of this revision.Dec 18 2022, 8:30 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 18 2022, 8:30 AM

Is there a test ?

If we emit . module or .nan for all functions in a single build unit, [...]

.module

llvm/lib/Target/Mips/MipsAsmPrinter.h
66 ↗(On Diff #483823)

Delete "isFirstFunction - " it's an obsoleted style of documentation.

Thanks for the fix! It does not appear to be enough though, I still see some of those errors in my build, although there are far fewer of them:

/tmp/syscall-69c080.s: Assembler messages:
/tmp/syscall-69c080.s:224: Error: .module is not permitted after generating code
clang-16: error: assembler command failed with exit code 1 (use -v to see invocation)
make[5]: *** [/home/nathan/cbl/src/linux/scripts/Makefile.build:250: arch/mips/kernel/syscall.o] Error 1

/tmp/traps-4cb796.s: Assembler messages:
/tmp/traps-4cb796.s:161: Error: .module is not permitted after generating code
clang-16: error: assembler command failed with exit code 1 (use -v to see invocation)
make[5]: *** [/home/nathan/cbl/src/linux/scripts/Makefile.build:250: arch/mips/kernel/traps.o] Error 1

/tmp/sys_ni-0c2210.s: Assembler messages:
/tmp/sys_ni-0c2210.s:538: Error: .module is not permitted after generating code
clang-16: error: assembler command failed with exit code 1 (use -v to see invocation)
make[4]: *** [/home/nathan/cbl/src/linux/scripts/Makefile.build:250: kernel/sys_ni.o] Error 1

/tmp/configs-c3d91c.s: Assembler messages:
/tmp/configs-c3d91c.s:134: Error: .module is not permitted after generating code
clang-16: error: assembler command failed with exit code 1 (use -v to see invocation)
make[4]: *** [/home/nathan/cbl/src/linux/scripts/Makefile.build:251: kernel/configs.o] Error 1

I can try to reduce something out if it would be useful, unless you see an immediate issue.

cvise spits out:

__asm__("       .previous                       \n");
void __attribute__set_raw_show_trace() {}
$ clang --target=mips-linux-gnu -fno-integrated-as -c -o /dev/null traps.i
/tmp/traps-0867c0.s: Assembler messages:
/tmp/traps-0867c0.s:23: Error: .module is not permitted after generating code
/tmp/traps-0867c0.s:26: Warning: .ent or .aent not in text section
/tmp/traps-0867c0.s:48: Warning: .end not in text section
clang-16: error: assembler command failed with exit code 1 (use -v to see invocation)

which appears to come from

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/mips/kernel/traps.c#n431

If this cannot be resolved by tomorrow, can the original patch be reverted and resubmitted with this fixed? This is breaking our and others' builds:

https://lore.kernel.org/CA+G9fYs=G_AAbkNOfLv7Oyvt6uOZ8CYun8fUQ-GghoKtbD5WAw@mail.gmail.com/

wzssyqa updated this revision to Diff 485793.Dec 31 2022, 7:27 PM
wzssyqa retitled this revision from MIPS: emit .module and .nan directives only for first function to MIPS: fix build from IR files, nan2008 and FpAbi.
wzssyqa edited the summary of this revision. (Show Details)
Herald added a project: Restricted Project. · View Herald TranscriptDec 31 2022, 7:27 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
wzssyqa added a comment.EditedDec 31 2022, 7:28 PM

@nathanchance can you have a try of this patch?

MaskRay added inline comments.Dec 31 2022, 10:54 PM
llvm/test/CodeGen/Mips/abiflags-2008-fp64.ll
1

Add ;; file-level comment what this test does.

This does not show any issues with any of the MIPS configurations that I build in the Linux kernel, thanks for fixing the problems I reported!

wzssyqa updated this revision to Diff 485897.Jan 2 2023, 5:28 PM
wzssyqa updated this revision to Diff 485898.
wzssyqa marked an inline comment as done.

ping

I don't know how to test this, so this will be up to @nathanchance ...
(Thanks for improving the mips port, though)

I tested this against the kernel and left my feedback above (no issues) so this can be merged.

MaskRay accepted this revision.Jan 30 2023, 11:59 AM

Thanks!

This revision is now accepted and ready to land.Jan 30 2023, 11:59 AM

@MaskRay can you help to submit this patch?

This revision was landed with ongoing or failed builds.Feb 6 2023, 8:36 PM
This revision was automatically updated to reflect the committed changes.