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

-mno-save-restore spams a RISCV Linux kernel build #44198

Closed
nathanchance opened this issue Feb 9, 2020 · 4 comments
Closed

-mno-save-restore spams a RISCV Linux kernel build #44198

nathanchance opened this issue Feb 9, 2020 · 4 comments
Labels
bugzilla Issues migrated from bugzilla clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl'

Comments

@nathanchance
Copy link
Member

Bugzilla Link 44853
Resolution FIXED
Resolved on Feb 12, 2020 10:36
Version trunk
OS All
CC @asb,@nickdesaulniers,@zygoloid,@lenary

Extended Description

When building the Linux kernel for RISCV, there is a bunch of warning spam around -mno-save-restore, which is explicitly specified in arch/riscv/Makefile.

$ make -j$(nproc) -s ARCH=riscv CC=clang-11 CROSS_COMPILE=riscv64-linux-gnu- O=out.riscv distclean defconfig all
...
'-save-restore' is not a recognized feature for this target (ignoring feature)
'-save-restore' is not a recognized feature for this target (ignoring feature)
'-save-restore' is not a recognized feature for this target (ignoring feature)
'-save-restore' is not a recognized feature for this target (ignoring feature)
...

I assume this warning is coming from the backend since -msave-restore warns from clang.

$ echo | clang-11 --target=riscv64-linux-gnu -msave-restore -c -x c -o /dev/null -
clang: warning: the clang compiler does not support '-msave-restore'
'+save-restore' is not a recognized feature for this target (ignoring feature)
$ echo | clang-11 --target=riscv64-linux-gnu -mno-save-restore -c -x c -o /dev/null -
'-save-restore' is not a recognized feature for this target (ignoring feature)

This warning happens on every translation unit so it is very noisy. We could silence it by just not passing -mno-save-restore when building with clang but that seems fragile in case -msave-restore ever became default. We’ll do whatever you feel is best though.

@lenary
Copy link
Member

lenary commented Feb 10, 2020

Please can you tell me exactly which LLVM version (including git revision, if you're on master) you are using?

HEAD, as of today (f2af4f8) does not include any code to translate -m{no-}save-restore into target features, only a warning is emitted (https://github.com/llvm/llvm-project/blob/f2af4f8a45dbd0d1de950a64f1b4fbf618c70657/clang/lib/Driver/ToolChains/Arch/RISCV.cpp#L437-441)

Have you applied some patches of your own?

@nathanchance
Copy link
Member Author

No, both the LLVM toolchain and Linux kernel are completely vanilla.

$ clang --version | head -n1
ClangBuiltLinux clang version 11.0.0 (git://github.com/llvm/llvm-project 8b81ebf)

$ git describe --contains
v5.6-rc1^0

$ make -j$(nproc) -s ARCH=riscv CC=clang CROSS_COMPILE=riscv64-linux-gnu- O=out.riscv distclean defconfig init/main.o
...
'-save-restore' is not a recognized feature for this target (ignoring feature)
'-save-restore' is not a recognized feature for this target (ignoring feature)
'-save-restore' is not a recognized feature for this target (ignoring feature)
'-save-restore' is not a recognized feature for this target (ignoring feature)
'-save-restore' is not a recognized feature for this target (ignoring feature)
'-save-restore' is not a recognized feature for this target (ignoring feature)
'-save-restore' is not a recognized feature for this target (ignoring feature)
...

The full command from that translation unit, if it is relevant:

clang -Wp,-MD,init/.main.o.d -nostdinc -isystem /home/nathan/cbl/git/tc-build/install/lib/clang/11.0.0/include -I../arch/riscv/include -I./arch/riscv/include/generated -I../include -I./include -I../arch/riscv/include/uapi -I./arch/riscv/include/generated/uapi -I../include/uapi -I./include/generated/uapi -include ../include/linux/kconfig.h -include ../include/linux/compiler_types.h -D__KERNEL__ -Qunused-arguments -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE -Werror=implicit-function-declaration -Werror=implicit-int -Wno-format-security -std=gnu89 --target=riscv64-linux-gnu --prefix=/home/nathan/cbl/git/tc-build/install/bin/ --gcc-toolchain=/home/nathan/cbl/git/tc-build/install -no-integrated-as -Werror=unknown-warning-option -mabi=lp64 -march=rv64imac -mno-save-restore -DCONFIG_PAGE_OFFSET=0xffffffe000000000 -mcmodel=medany -fno-delete-null-pointer-checks -Wno-address-of-packed-member -O2 -Wframe-larger-than=2048 -fno-stack-protector -Wno-format-invalid-specifier -Wno-gnu -Wno-tautological-compare -mno-global-merge -Wno-unused-const-variable -fno-omit-frame-pointer -fno-optimize-sibling-calls -Wdeclaration-after-statement -Wvla -Wno-pointer-sign -fno-strict-overflow -fno-merge-all-constants -fno-stack-check -Werror=date-time -Werror=incompatible-pointer-types -fmacro-prefix-map=../= -Wno-initializer-overrides -Wno-format -Wno-sign-compare -Wno-format-zero-length -fno-function-sections -fno-data-sections -I ../init -I ./init -DKBUILD_MODFILE='"init/main"' -DKBUILD_BASENAME='"main"' -DKBUILD_MODNAME='"main"' -c -o init/main.o ../init/main.c

@lenary
Copy link
Member

lenary commented Feb 12, 2020

I cannot find "-save-restore" in any of the clang or llvm source code as of commit 8b81ebfe7eba089ed2016d523cc5ee9d05e957a7, or any of the clangbuiltlinux source code either (it would be in -mattr or the like).

I think maybe this warning is coming from some cached target-features somewhere, in a LLVM IR file or the like.

The "save-restore" feature has only been parts of patches until today, I believe, so I don't think any mainline clang version has been generating code with the save-restore feature yet.

That said, save-restore has now landed, so maybe now these warnings will go away on HEAD? Do let me know how you get on on today's HEAD.

@nathanchance
Copy link
Member Author

Yes, these warnings are gone with my version of clang at bc316c2, I'll close this, thank you!

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl'
Projects
None yet
Development

No branches or pull requests

2 participants