Skip to contentSkip to conversation

"arm64: vdso: Substitute gettimeofday() with C implementation" breaks clang build

DISCUSSION Qian Cai 4 participants 16 messages Jun 25, 2019 – Jun 26, 2019 arm64

lore
Share & tools
lore

Qian Cai

author
#0 lore raw

The linux-next commit "arm64: vdso: Substitute gettimeofday() with C implementation" [1] breaks clang build.

error: invalid value 'tiny' in '-mcode-model tiny' make[1]: *** [scripts/Makefile.build:279:
arch/arm64/kernel/vdso/vgettimeofday.o] Error 1 make[1]: *** Waiting for unfinished jobs....
make: *** [arch/arm64/Makefile:180: vdso_prepare] Error 2

[1] https://patchwork.kernel.org/patch/11009663/

#1 lore raw

Hi Qian,

Quoted 11 lines · Qian Cai

The linux-next commit "arm64: vdso: Substitute gettimeofday() with C implementation" [1] breaks clang build.

error: invalid value 'tiny' in '-mcode-model tiny' make[1]: *** [scripts/Makefile.build:279:
arch/arm64/kernel/vdso/vgettimeofday.o] Error 1 make[1]: *** Waiting for unfinished jobs....
make: *** [arch/arm64/Makefile:180: vdso_prepare] Error 2

[1] https://patchwork.kernel.org/patch/11009663/

I am not sure what does exactly break from your report. Could you please provide more details?

On my env:

$ make mrproper && make defconfig && make CC=clang HOSTCC=clang -j$(nproc)

...

arch/arm64/Makefile:56: CROSS_COMPILE_COMPAT is clang, the compat vDSO will not be built

...

  LDS     arch/arm64/kernel/vdso/vdso.lds
  AS      arch/arm64/kernel/vdso/note.o
  AS      arch/arm64/kernel/vdso/sigreturn.o
  CC      arch/arm64/kernel/vdso/vgettimeofday.o
  LD      arch/arm64/kernel/vdso/vdso.so.dbg

VDSOCHK arch/arm64/kernel/vdso/vdso.so.dbg
VDSOSYM include/generated/vdso-offsets.h

...

LD vmlinux.o
MODPOST vmlinux.o
MODINFO modules.builtin.modinfo

  KSYM    .tmp_kallsyms1.o
  KSYM    .tmp_kallsyms2.o
  LD      vmlinux
  SORTEX  vmlinux
  SYSMAP  System.map

Building modules, stage 2.
OBJCOPY arch/arm64/boot/Image
MODPOST 483 modules

Signature · 2 lines
Regards,
Vincenzo
author
#2 lore raw
Quoted 12 lines · Vincenzo Frascino

Hi Qian,

Quoted 9 lines · Qian Cai

The linux-next commit "arm64: vdso: Substitute gettimeofday() with C implementation" [1] breaks clang build.

error: invalid value 'tiny' in '-mcode-model tiny' make[1]: *** [scripts/Makefile.build:279:
arch/arm64/kernel/vdso/vgettimeofday.o] Error 1 make[1]: *** Waiting for unfinished jobs....
make: *** [arch/arm64/Makefile:180: vdso_prepare] Error 2

Quoted 6 lines
Quoted 2 lines

[1] https://patchwork.kernel.org/patch/11009663/

I am not sure what does exactly break from your report. Could you please provide
more details?

Here is the config to reproduce.

https://raw.githubusercontent.com/cailca/linux-mm/master/arm64.config

# make CC=clang -j $(nr_cpus)

I can get it working again by removing "-mcmodel=tiny" in arch/arm64/kernel/vdso/Makefile

Quoted 35 lines

On my env:

$ make mrproper && make defconfig && make CC=clang HOSTCC=clang -j$(nproc)

...

arch/arm64/Makefile:56: CROSS_COMPILE_COMPAT is clang, the compat vDSO will not
be built

...

  LDS     arch/arm64/kernel/vdso/vdso.lds
  AS      arch/arm64/kernel/vdso/note.o
  AS      arch/arm64/kernel/vdso/sigreturn.o
  CC      arch/arm64/kernel/vdso/vgettimeofday.o
  LD      arch/arm64/kernel/vdso/vdso.so.dbg
  VDSOCHK arch/arm64/kernel/vdso/vdso.so.dbg
  VDSOSYM include/generated/vdso-offsets.h

...

  LD      vmlinux.o
  MODPOST vmlinux.o
  MODINFO modules.builtin.modinfo
  KSYM    .tmp_kallsyms1.o
  KSYM    .tmp_kallsyms2.o
  LD      vmlinux
  SORTEX  vmlinux
  SYSMAP  System.map
  Building modules, stage 2.
  OBJCOPY arch/arm64/boot/Image
  MODPOST 483 modules

#3 lore raw

Hi Qin,

Quoted 20 lines · Qian Cai
Quoted 12 lines · Vincenzo Frascino

Hi Qian,

Quoted 9 lines · Qian Cai

The linux-next commit "arm64: vdso: Substitute gettimeofday() with C implementation" [1] breaks clang build.

error: invalid value 'tiny' in '-mcode-model tiny' make[1]: *** [scripts/Makefile.build:279:
arch/arm64/kernel/vdso/vgettimeofday.o] Error 1 make[1]: *** Waiting for unfinished jobs....
make: *** [arch/arm64/Makefile:180: vdso_prepare] Error 2

Quoted 6 lines
Quoted 2 lines

[1] https://patchwork.kernel.org/patch/11009663/

I am not sure what does exactly break from your report. Could you please provide
more details?

Quoted 9 lines

Here is the config to reproduce.

https://raw.githubusercontent.com/cailca/linux-mm/master/arm64.config

# make CC=clang -j $(nr_cpus)

I can get it working again by removing "-mcmodel=tiny" in arch/arm64/kernel/vdso/Makefile

With your defconfig I can't still reproduce the problem. Which version of clang are you using?

Quoted 35 lines
Quoted 35 lines

On my env:

$ make mrproper && make defconfig && make CC=clang HOSTCC=clang -j$(nproc)

...

arch/arm64/Makefile:56: CROSS_COMPILE_COMPAT is clang, the compat vDSO will not
be built

...

  LDS     arch/arm64/kernel/vdso/vdso.lds
  AS      arch/arm64/kernel/vdso/note.o
  AS      arch/arm64/kernel/vdso/sigreturn.o
  CC      arch/arm64/kernel/vdso/vgettimeofday.o
  LD      arch/arm64/kernel/vdso/vdso.so.dbg
  VDSOCHK arch/arm64/kernel/vdso/vdso.so.dbg
  VDSOSYM include/generated/vdso-offsets.h

...

  LD      vmlinux.o
  MODPOST vmlinux.o
  MODINFO modules.builtin.modinfo
  KSYM    .tmp_kallsyms1.o
  KSYM    .tmp_kallsyms2.o
  LD      vmlinux
  SORTEX  vmlinux
  SYSMAP  System.map
  Building modules, stage 2.
  OBJCOPY arch/arm64/boot/Image
  MODPOST 483 modules

Signature · 2 lines
Regards,
Vincenzo
author
#4 lore raw
Quoted 27 lines · Vincenzo Frascino
Quoted 26 lines · Qian Cai
Quoted 12 lines · Vincenzo Frascino

Hi Qian,

Quoted 9 lines · Qian Cai

The linux-next commit "arm64: vdso: Substitute gettimeofday() with C implementation" [1] breaks clang build.

error: invalid value 'tiny' in '-mcode-model tiny' make[1]: *** [scripts/Makefile.build:279:
arch/arm64/kernel/vdso/vgettimeofday.o] Error 1 make[1]: *** Waiting for unfinished jobs....
make: *** [arch/arm64/Makefile:180: vdso_prepare] Error 2

Quoted 6 lines
Quoted 2 lines

[1] https://patchwork.kernel.org/patch/11009663/

I am not sure what does exactly break from your report. Could you please provide
more details?

Here is the config to reproduce.

https://raw.githubusercontent.com/cailca/linux-mm/master/arm64.config

# make CC=clang -j $(nr_cpus)
Quoted 7 lines
Quoted 3 lines

I can get it working again by removing "-mcmodel=tiny" in arch/arm64/kernel/vdso/Makefile

With your defconfig I can't still reproduce the problem. Which version of clang
are you using?

Compiler: clang version 7.0.1 (tags/RELEASE_701/final)

Quoted 39 lines
Quoted 37 lines
Quoted 37 lines

On my env:

$ make mrproper && make defconfig && make CC=clang HOSTCC=clang -j$(nproc)

...

arch/arm64/Makefile:56: CROSS_COMPILE_COMPAT is clang, the compat vDSO will
not
be built

...

  LDS     arch/arm64/kernel/vdso/vdso.lds
  AS      arch/arm64/kernel/vdso/note.o
  AS      arch/arm64/kernel/vdso/sigreturn.o
  CC      arch/arm64/kernel/vdso/vgettimeofday.o
  LD      arch/arm64/kernel/vdso/vdso.so.dbg
  VDSOCHK arch/arm64/kernel/vdso/vdso.so.dbg
  VDSOSYM include/generated/vdso-offsets.h

...

  LD      vmlinux.o
  MODPOST vmlinux.o
  MODINFO modules.builtin.modinfo
  KSYM    .tmp_kallsyms1.o
  KSYM    .tmp_kallsyms2.o
  LD      vmlinux
  SORTEX  vmlinux
  SYSMAP  System.map
  Building modules, stage 2.
  OBJCOPY arch/arm64/boot/Image
  MODPOST 483 modules

#5 lore raw

Hi Qian,

Quoted 32 lines · Qian Cai
Quoted 31 lines · Vincenzo Frascino
Quoted 29 lines · Qian Cai
Quoted 12 lines · Vincenzo Frascino

Hi Qian,

Quoted 9 lines · Qian Cai

The linux-next commit "arm64: vdso: Substitute gettimeofday() with C implementation" [1] breaks clang build.

error: invalid value 'tiny' in '-mcode-model tiny' make[1]: *** [scripts/Makefile.build:279:
arch/arm64/kernel/vdso/vgettimeofday.o] Error 1 make[1]: *** Waiting for unfinished jobs....
make: *** [arch/arm64/Makefile:180: vdso_prepare] Error 2

Quoted 6 lines
Quoted 2 lines

[1] https://patchwork.kernel.org/patch/11009663/

I am not sure what does exactly break from your report. Could you please provide
more details?

Here is the config to reproduce.

https://raw.githubusercontent.com/cailca/linux-mm/master/arm64.config

# make CC=clang -j $(nr_cpus)

I can get it working again by removing "-mcmodel=tiny" in arch/arm64/kernel/vdso/Makefile

Quoted 6 lines
Quoted 3 lines

With your defconfig I can't still reproduce the problem. Which version of clang
are you using?

Compiler: clang version 7.0.1 (tags/RELEASE_701/final)

I am using clang 8.0.0. Could you please try with it and see if the issue goes away?

Thanks,
Vincenzo

Quoted 39 lines
Quoted 39 lines
Quoted 37 lines
Quoted 37 lines

On my env:

$ make mrproper && make defconfig && make CC=clang HOSTCC=clang -j$(nproc)

...

arch/arm64/Makefile:56: CROSS_COMPILE_COMPAT is clang, the compat vDSO will
not
be built

...

  LDS     arch/arm64/kernel/vdso/vdso.lds
  AS      arch/arm64/kernel/vdso/note.o
  AS      arch/arm64/kernel/vdso/sigreturn.o
  CC      arch/arm64/kernel/vdso/vgettimeofday.o
  LD      arch/arm64/kernel/vdso/vdso.so.dbg
  VDSOCHK arch/arm64/kernel/vdso/vdso.so.dbg
  VDSOSYM include/generated/vdso-offsets.h

...

  LD      vmlinux.o
  MODPOST vmlinux.o
  MODINFO modules.builtin.modinfo
  KSYM    .tmp_kallsyms1.o
  KSYM    .tmp_kallsyms2.o
  LD      vmlinux
  SORTEX  vmlinux
  SYSMAP  System.map
  Building modules, stage 2.
  OBJCOPY arch/arm64/boot/Image
  MODPOST 483 modules

Signature · 2 lines
Regards,
Vincenzo
author
#6 lore raw
Quoted 40 lines · Vincenzo Frascino

Hi Qian,

Quoted 37 lines · Qian Cai
Quoted 35 lines · Vincenzo Frascino
Quoted 21 lines · Qian Cai
Quoted 12 lines · Vincenzo Frascino

Hi Qian,

Quoted 9 lines · Qian Cai

The linux-next commit "arm64: vdso: Substitute gettimeofday() with C implementation" [1] breaks clang build.

error: invalid value 'tiny' in '-mcode-model tiny' make[1]: *** [scripts/Makefile.build:279:
arch/arm64/kernel/vdso/vgettimeofday.o] Error 1 make[1]: *** Waiting for unfinished jobs....
make: *** [arch/arm64/Makefile:180: vdso_prepare] Error 2

Quoted 7 lines
Quoted 2 lines

[1] https://patchwork.kernel.org/patch/11009663/

I am not sure what does exactly break from your report. Could you please
provide
more details?

Quoted 9 lines

Here is the config to reproduce.

https://raw.githubusercontent.com/cailca/linux-mm/master/arm64.config

# make CC=clang -j $(nr_cpus)

I can get it working again by removing "-mcmodel=tiny" in arch/arm64/kernel/vdso/Makefile

With your defconfig I can't still reproduce the problem. Which version of clang
are you using?

Quoted 5 lines
Quoted 2 lines

Compiler: clang version 7.0.1 (tags/RELEASE_701/final)

I am using clang 8.0.0. Could you please try with it and see if the issue goes away?

Looks like the "tiny" was added since clang 8.0.

https://reviews.llvm.org/D49674

but clang 7.0 is still use in many distros by default, so maybe this commit can be fixed by adding a conditional check to use "small" if clang version < 8.0.

Quoted 46 lines

Thanks,
Vincenzo

Quoted 40 lines
Quoted 40 lines
Quoted 38 lines
Quoted 38 lines

On my env:

$ make mrproper && make defconfig && make CC=clang HOSTCC=clang
-j$(nproc)

...

arch/arm64/Makefile:56: CROSS_COMPILE_COMPAT is clang, the compat vDSO will
not
be built

...

  LDS     arch/arm64/kernel/vdso/vdso.lds
  AS      arch/arm64/kernel/vdso/note.o
  AS      arch/arm64/kernel/vdso/sigreturn.o
  CC      arch/arm64/kernel/vdso/vgettimeofday.o
  LD      arch/arm64/kernel/vdso/vdso.so.dbg
  VDSOCHK arch/arm64/kernel/vdso/vdso.so.dbg
  VDSOSYM include/generated/vdso-offsets.h

...

  LD      vmlinux.o
  MODPOST vmlinux.o
  MODINFO modules.builtin.modinfo
  KSYM    .tmp_kallsyms1.o
  KSYM    .tmp_kallsyms2.o
  LD      vmlinux
  SORTEX  vmlinux
  SYSMAP  System.map
  Building modules, stage 2.
  OBJCOPY arch/arm64/boot/Image
  MODPOST 483 modules

#7 lore raw

Hi Qian,

Quoted 47 lines · Qian Cai
Quoted 40 lines · Vincenzo Frascino

Hi Qian,

Quoted 37 lines · Qian Cai
Quoted 35 lines · Vincenzo Frascino
Quoted 21 lines · Qian Cai
Quoted 12 lines · Vincenzo Frascino

Hi Qian,

Quoted 9 lines · Qian Cai

The linux-next commit "arm64: vdso: Substitute gettimeofday() with C implementation" [1] breaks clang build.

error: invalid value 'tiny' in '-mcode-model tiny' make[1]: *** [scripts/Makefile.build:279:
arch/arm64/kernel/vdso/vgettimeofday.o] Error 1 make[1]: *** Waiting for unfinished jobs....
make: *** [arch/arm64/Makefile:180: vdso_prepare] Error 2

Quoted 7 lines
Quoted 2 lines

[1] https://patchwork.kernel.org/patch/11009663/

I am not sure what does exactly break from your report. Could you please
provide
more details?

Quoted 9 lines

Here is the config to reproduce.

https://raw.githubusercontent.com/cailca/linux-mm/master/arm64.config

# make CC=clang -j $(nr_cpus)

I can get it working again by removing "-mcmodel=tiny" in arch/arm64/kernel/vdso/Makefile

With your defconfig I can't still reproduce the problem. Which version of clang
are you using?

Quoted 5 lines
Quoted 2 lines

Compiler: clang version 7.0.1 (tags/RELEASE_701/final)

I am using clang 8.0.0. Could you please try with it and see if the issue goes away?

Quoted 7 lines

Looks like the "tiny" was added since clang 8.0.

https://reviews.llvm.org/D49674

but clang 7.0 is still use in many distros by default, so maybe this commit can be fixed by adding a conditional check to use "small" if clang version < 8.0.

It is what I thought that's why I asked to cross-check. I did not want to remove tiny.

Thanks for your support, I will post a patch adding your tag as reported-by if you are ok with that.

Quoted 46 lines
Quoted 46 lines

Thanks,
Vincenzo

Quoted 40 lines
Quoted 40 lines
Quoted 38 lines
Quoted 38 lines

On my env:

$ make mrproper && make defconfig && make CC=clang HOSTCC=clang
-j$(nproc)

...

arch/arm64/Makefile:56: CROSS_COMPILE_COMPAT is clang, the compat vDSO will
not
be built

...

  LDS     arch/arm64/kernel/vdso/vdso.lds
  AS      arch/arm64/kernel/vdso/note.o
  AS      arch/arm64/kernel/vdso/sigreturn.o
  CC      arch/arm64/kernel/vdso/vgettimeofday.o
  LD      arch/arm64/kernel/vdso/vdso.so.dbg
  VDSOCHK arch/arm64/kernel/vdso/vdso.so.dbg
  VDSOSYM include/generated/vdso-offsets.h

...

  LD      vmlinux.o
  MODPOST vmlinux.o
  MODINFO modules.builtin.modinfo
  KSYM    .tmp_kallsyms1.o
  KSYM    .tmp_kallsyms2.o
  LD      vmlinux
  SORTEX  vmlinux
  SYSMAP  System.map
  Building modules, stage 2.
  OBJCOPY arch/arm64/boot/Image
  MODPOST 483 modules

Signature · 2 lines
Regards,
Vincenzo
#8 lore raw
In reply to Qian Cai

Hi Qian,

...

Quoted 4 lines

but clang 7.0 is still use in many distros by default, so maybe this commit can be fixed by adding a conditional check to use "small" if clang version < 8.0.

Could you please verify that the patch below works for you?

Thanks,
Vincenzo

--->8----

From 0546f3bbea910cd26df8c2ff9ed1a59945bb1bec Mon Sep 17 00:00:00 2001
From: Vincenzo Frascino <[email protected]>
Date: Tue, 25 Jun 2019 15:49:37 +0100
Subject: [PATCH] arm64: vdso: Fix compilation with clang < 8

clang versions previous to 8 do not support -mcmodel=tiny.

Add a check to the vDSO Makefile for arm64 to remove the flag when these versions of the compiler are detected.

---
 arch/arm64/kernel/vdso/Makefile | 5 +++++
 1 file changed, 5 insertions(+)
arch/arm64/kernel/vdso/Makefile +5 -0
index ec81d28aeb5d..c11cbf71073f 100644
@@ -38,6 +38,11 @@ else
 CFLAGS_vgettimeofday.o = -O2 -mcmodel=tiny -include $(c-gettimeofday-y)
 endif
 
+# Clang versions less than 8 do not support -mcmodel=tiny
+ifeq ($(shell test $(CONFIG_CLANG_VERSION) -lt 80000; echo $$?),0)
+CFLAGS_REMOVE_vgettimeofday.o = -mcmodel=tiny
+endif
+
 # Disable gcov profiling for VDSO code
 GCOV_PROFILE := n
 
Signature · 1 line
2.22.0
author
#9 lore raw
Quoted 11 lines · Vincenzo Frascino

Hi Qian,

...

Quoted 6 lines

but clang 7.0 is still use in many distros by default, so maybe this commit can
be fixed by adding a conditional check to use "small" if clang version < 8.0.

Quoted 7 lines

Could you please verify that the patch below works for you?

Thanks,
Vincenzo

--->8----

It does not work unfortunately.

# make CC=clang -j 256 2>/tmp/warn3.txt
  HOSTCC  scripts/basic/fixdep
  HOSTCC  scripts/dtc/dtc.o
  HOSTCC  scripts/dtc/flattree.o
  HOSTCC  scripts/dtc/fstree.o
  HOSTCC  scripts/dtc/data.o
  HOSTCC  scripts/dtc/livetree.o
  HOSTCC  scripts/dtc/treesource.o
  HOSTCC  scripts/dtc/srcpos.o
  HOSTCC  scripts/dtc/checks.o
  HOSTCC  scripts/dtc/util.o
  LEX     scripts/dtc/dtc-lexer.lex.c
  YACC    scripts/dtc/dtc-parser.tab.h
  YACC    scripts/dtc/dtc-parser.tab.c
  HOSTCC  scripts/dtc/dtc-parser.tab.o
  HOSTCC  scripts/dtc/dtc-lexer.lex.o
  HOSTLD  scripts/dtc/dtc
  HOSTCC  scripts/kallsyms
  HOSTCC  scripts/recordmcount
  HOSTCC  scripts/sortextable
  DTC     arch/arm64/boot/dts/arm/foundation-v8.dtb
  DTC     arch/arm64/boot/dts/arm/foundation-v8-psci.dtb
  DTC     arch/arm64/boot/dts/arm/foundation-v8-gicv3.dtb
  DTC     arch/arm64/boot/dts/arm/foundation-v8-gicv3-psci.dtb
  DTC     arch/arm64/boot/dts/arm/juno.dtb
  DTC     arch/arm64/boot/dts/arm/juno-r1.dtb
  DTC     arch/arm64/boot/dts/arm/juno-r2.dtb
  DTC     arch/arm64/boot/dts/arm/rtsm_ve-aemv8a.dtb
  DTC     arch/arm64/boot/dts/arm/vexpress-v2f-1xv7-ca53x2.dtb
  DTC     arch/arm64/boot/dts/arm/fvp-base-revc.dtb
  DTC     arch/arm64/boot/dts/cavium/thunder2-99xx.dtb
  DTC     arch/arm64/boot/dts/hisilicon/hi3660-hikey960.dtb
  DTC     arch/arm64/boot/dts/hisilicon/hi3670-hikey970.dtb
  DTC     arch/arm64/boot/dts/hisilicon/hi3798cv200-poplar.dtb
  DTC     arch/arm64/boot/dts/hisilicon/hi6220-hikey.dtb
  DTC     arch/arm64/boot/dts/hisilicon/hip05-d02.dtb
  DTC     arch/arm64/boot/dts/hisilicon/hip06-d03.dtb
  DTC     arch/arm64/boot/dts/hisilicon/hip07-d05.dtb
  HOSTCC  scripts/mod/mk_elfconfig
  CC      scripts/mod/devicetable-offsets.s
  CC      scripts/mod/empty.o
  MKELF   scripts/mod/elfconfig.h
  HOSTCC  scripts/mod/modpost.o
  HOSTCC  scripts/mod/file2alias.o
  HOSTCC  scripts/mod/sumversion.o
  HOSTLD  scripts/mod/modpost
  CC      kernel/bounds.s
  CALL    scripts/atomic/check-atomics.sh
  CC      arch/arm64/kernel/asm-offsets.s
  CALL    scripts/checksyscalls.sh
  LDS     arch/arm64/kernel/vdso/vdso.lds
  AS      arch/arm64/kernel/vdso/note.o
  AS      arch/arm64/kernel/vdso/sigreturn.o
  CC      arch/arm64/kernel/vdso/vgettimeofday.o
  LD      arch/arm64/kernel/vdso/vdso.so.dbg
  VDSOCHK arch/arm64/kernel/vdso/vdso.so.dbg
00000000000009d0 R_AARCH64_JUMP_SLOT  _mcount

arch/arm64/kernel/vdso/vdso.so.dbg: dynamic relocations are not supported make[1]: *** [arch/arm64/kernel/vdso/Makefile:59:
arch/arm64/kernel/vdso/vdso.so.dbg] Error 1
make: *** [arch/arm64/Makefile:180: vdso_prepare] Error 2

#10 lore raw
In reply to Vincenzo Frascino
Quoted 11 lines · Vincenzo Frascino

Hi Qian,

...

Quoted 4 lines

but clang 7.0 is still use in many distros by default, so maybe this commit can be fixed by adding a conditional check to use "small" if clang version < 8.0.

Could you please verify that the patch below works for you?

Should it be checking against CONFIG_CLANG_VERSION, or better yet be using cc-option macro?

Signature · 2 lines
Thanks,
~Nick Desaulniers
#11 lore raw

Hi Nick,

Quoted 8 lines · Nick Desaulniers
Quoted 6 lines · Vincenzo Frascino

Hi Qian,

...

Quoted 1 line
Quoted 9 lines
Quoted 5 lines
Quoted 3 lines

but clang 7.0 is still use in many distros by default, so maybe this commit can be fixed by adding a conditional check to use "small" if clang version < 8.0.

Could you please verify that the patch below works for you?

Should it be checking against CONFIG_CLANG_VERSION, or better yet be using cc-option macro?

This is what I did in my proposed patch, but I was surprised that clang-7 generates relocations that clang-8 does not.

LD arch/arm64/kernel/vdso/vdso.so.dbg
VDSOCHK arch/arm64/kernel/vdso/vdso.so.dbg
00000000000009d0 R_AARCH64_JUMP_SLOT _mcount

arch/arm64/kernel/vdso/vdso.so.dbg: dynamic relocations are not supported make[1]: *** [arch/arm64/kernel/vdso/Makefile:59:
arch/arm64/kernel/vdso/vdso.so.dbg] Error 1
make: *** [arch/arm64/Makefile:180: vdso_prepare] Error 2

This is the the result of the macro I introduced in lib/vdso/Makefile.

And I just found out why. I forgot to add a "+" in the patch provided :)

@Qian: Could you please retry with the one provided below?

Signature · 4 lines
Regards,
Vincenzo

--->8----

From eed9ea23cf999d31b87db4b98a8e9de209706132 Mon Sep 17 00:00:00 2001
From: Vincenzo Frascino <[email protected]>
Date: Tue, 25 Jun 2019 15:49:37 +0100
Subject: [PATCH] arm64: vdso: Fix compilation with clang < 8

clang versions previous to 8 do not support -mcmodel=tiny.

Add a check to the vDSO Makefile for arm64 to remove the flag when these versions of the compiler are detected.

---
 arch/arm64/kernel/vdso/Makefile | 5 +++++
 1 file changed, 5 insertions(+)
arch/arm64/kernel/vdso/Makefile +5 -0
index ec81d28aeb5d..5154f50aff2d 100644
@@ -38,6 +38,11 @@ else
 CFLAGS_vgettimeofday.o = -O2 -mcmodel=tiny -include $(c-gettimeofday-y)
 endif
 
+# Clang versions less than 8 do not support -mcmodel=tiny
+ifeq ($(shell test $(CONFIG_CLANG_VERSION) -lt 80000; echo $$?),0)
+CFLAGS_REMOVE_vgettimeofday.o += -mcmodel=tiny
+endif
+
 # Disable gcov profiling for VDSO code
 GCOV_PROFILE := n
 
Signature · 1 line
2.22.0
author
#12 lore raw
Quoted 35 lines · Vincenzo Frascino

Hi Nick,

Quoted 14 lines · Nick Desaulniers
Quoted 12 lines · Vincenzo Frascino

Hi Qian,

...

Quoted 6 lines

but clang 7.0 is still use in many distros by default, so maybe this commit can
be fixed by adding a conditional check to use "small" if clang version < 8.0.

Quoted 5 lines
Quoted 1 line

Could you please verify that the patch below works for you?

Should it be checking against CONFIG_CLANG_VERSION, or better yet be using cc-option macro?

This is what I did in my proposed patch, but I was surprised that clang-7 generates relocations that clang-8 does not.

  LD      arch/arm64/kernel/vdso/vdso.so.dbg
  VDSOCHK arch/arm64/kernel/vdso/vdso.so.dbg
00000000000009d0 R_AARCH64_JUMP_SLOT  _mcount

arch/arm64/kernel/vdso/vdso.so.dbg: dynamic relocations are not supported make[1]: *** [arch/arm64/kernel/vdso/Makefile:59:
arch/arm64/kernel/vdso/vdso.so.dbg] Error 1
make: *** [arch/arm64/Makefile:180: vdso_prepare] Error 2

Quoted 6 lines

This is the the result of the macro I introduced in lib/vdso/Makefile.

And I just found out why. I forgot to add a "+" in the patch provided :)

@Qian: Could you please retry with the one provided below?

It works fine.

#13 lore raw

Hi Qian,

Quoted 36 lines · Qian Cai
Quoted 35 lines · Vincenzo Frascino

Hi Nick,

Quoted 14 lines · Nick Desaulniers
Quoted 12 lines · Vincenzo Frascino

Hi Qian,

...

Quoted 6 lines

but clang 7.0 is still use in many distros by default, so maybe this commit can
be fixed by adding a conditional check to use "small" if clang version < 8.0.

Quoted 5 lines
Quoted 1 line

Could you please verify that the patch below works for you?

Should it be checking against CONFIG_CLANG_VERSION, or better yet be using cc-option macro?

This is what I did in my proposed patch, but I was surprised that clang-7 generates relocations that clang-8 does not.

  LD      arch/arm64/kernel/vdso/vdso.so.dbg
  VDSOCHK arch/arm64/kernel/vdso/vdso.so.dbg
00000000000009d0 R_AARCH64_JUMP_SLOT  _mcount

arch/arm64/kernel/vdso/vdso.so.dbg: dynamic relocations are not supported make[1]: *** [arch/arm64/kernel/vdso/Makefile:59:
arch/arm64/kernel/vdso/vdso.so.dbg] Error 1
make: *** [arch/arm64/Makefile:180: vdso_prepare] Error 2

Quoted 9 lines
Quoted 6 lines

This is the the result of the macro I introduced in lib/vdso/Makefile.

And I just found out why. I forgot to add a "+" in the patch provided :)

@Qian: Could you please retry with the one provided below?

It works fine.

Thanks for the confirmation, I will push the patch in a short while.

Signature · 2 lines
Regards,
Vincenzo
maintainer
#14 lore raw
In reply to Vincenzo Frascino
Quoted 13 lines · Vincenzo Frascino
Quoted 11 lines · Nick Desaulniers
Quoted 5 lines · Vincenzo Frascino
Quoted 3 lines

but clang 7.0 is still use in many distros by default, so maybe this commit can be fixed by adding a conditional check to use "small" if clang version < 8.0.

Could you please verify that the patch below works for you?

Should it be checking against CONFIG_CLANG_VERSION, or better yet be using cc-option macro?

Quoted 6 lines

This is what I did in my proposed patch, but I was surprised that clang-7 generates relocations that clang-8 does not.

LD arch/arm64/kernel/vdso/vdso.so.dbg
VDSOCHK arch/arm64/kernel/vdso/vdso.so.dbg
00000000000009d0 R_AARCH64_JUMP_SLOT _mcount

Hmm. It would be nice to understand where the reference to _mcount is coming from, since that sounds like ftrace is getting involved where it shouldn't be.

Will

#15 lore raw
Quoted 17 lines · Will Deacon
Quoted 16 lines · Vincenzo Frascino
Quoted 11 lines · Nick Desaulniers
Quoted 5 lines · Vincenzo Frascino
Quoted 3 lines

but clang 7.0 is still use in many distros by default, so maybe this commit can be fixed by adding a conditional check to use "small" if clang version < 8.0.

Could you please verify that the patch below works for you?

Should it be checking against CONFIG_CLANG_VERSION, or better yet be using cc-option macro?

This is what I did in my proposed patch, but I was surprised that clang-7 generates relocations that clang-8 does not.

Quoted 8 lines
Quoted 3 lines

LD arch/arm64/kernel/vdso/vdso.so.dbg
VDSOCHK arch/arm64/kernel/vdso/vdso.so.dbg
00000000000009d0 R_AARCH64_JUMP_SLOT _mcount

Hmm. It would be nice to understand where the reference to _mcount is coming from, since that sounds like ftrace is getting involved where it shouldn't be.

That's very true, it was a mistake in the Makefile change that I provided with the original iteration of this patch, that had as a side effect of having ftrace involved (_mcount is defined in entry-ftrace.c).

I was overriding:

CFLAGS_REMOVE_vgettimeofday.o = $(CC_FLAGS_FTRACE) -Os

with:

CFLAGS_REMOVE_vgettimeofday.o = -mcmodel=tiny (selected if clang is < 8)

that's why I said that I missed a "+" in my previous patch.

Having:

CFLAGS_REMOVE_vgettimeofday.o += -mcmodel=tiny

restores the wanted behavior.

Sorry for not being clear in my explanation.

Quoted 2 lines

Will

Signature · 2 lines
Regards,
Vincenzo