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

Issues with using with master of kernel #3

Open
b-ncMN opened this issue May 28, 2021 · 1 comment
Open

Issues with using with master of kernel #3

b-ncMN opened this issue May 28, 2021 · 1 comment

Comments

@b-ncMN
Copy link

b-ncMN commented May 28, 2021

An error is occurring when using kninja against master (I've tested up to v5.12) at the ninja -d explain -n

command "ninja -d explain -n" ran manually :

ninja: error: build.ninja:91096: unknown build rule 'cmd_arch_x86_entry_syscalls_built-in.a'
    cmd_arch_x86_entry_syscalls_built-in.a
    ^ near here

full stacktrace :

Traceback (most recent call last):
  File "/home/build-testing/src/linux/../kninja/kninja.py", line 368, in <module>
    main()
  File "/home/build-testing/src/linux/../kninja/kninja.py", line 359, in main
    out = subprocess.check_output(cmd, stderr=subprocess.STDOUT).decode('utf-8')
  File "/usr/lib/python3.9/subprocess.py", line 424, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/usr/lib/python3.9/subprocess.py", line 528, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['ninja', '-d', 'explain', '-n']' returned non-zero exit status 1.
@martinetd
Copy link

They've apparently added some dummy rules for lib.a and built-in.a files with no dependencies (e.g. only foo/lib.a: FORCE for the rule)

I was able to work around this problem by skipping such rules in the conversion, as no file is actually created by make in these case:

diff --git a/kninja.py b/kninja.py
index 5d814620eeb8..e303e6f3b627 100755
--- a/kninja.py
+++ b/kninja.py
@@ -184,6 +184,8 @@ class Kninja(object):
                     continue
 
                 deps = [d for d in deps.split(' ') if d != 'FORCE' and d not in IGNORES]
+                if not deps:
+                    continue
                 handledfiles.update(deps)
                 fixed = self.fixname(obj)
 

unfortunately while that passes the initial ninja explain check, it fails real world rebuilds (at least for my cross build with BTF enabled) -- it didn't build the .o file as expected and pahole couldn't handle it (+ other scary warnings before that):

[4/5] cat Makefile | sed -e '/^$(vmlinux-dirs)/,+1d' | make -f - all
  GEN     Makefile
  CALL    ../scripts/checksyscalls.sh
  CALL    ../scripts/atomic/check-atomics.sh
  DESCEND  bpf/resolve_btfids
  CHK     include/generated/compile.h
  CHK     kernel/kheaders_data.tar.xz
  GEN     .version
  CHK     include/generated/compile.h
  UPD     include/generated/compile.h
  CC      init/version.o
  AR      init/built-in.a
  LD      vmlinux.o
  MODPOST vmlinux.symvers
WARNING: modpost: EXPORT symbol "mmc_pwrseq_register" [vmlinux] version generation failed, symbol will not be versioned.
WARNING: modpost: EXPORT symbol "mmc_pwrseq_unregister" [vmlinux] version generation failed, symbol will not be versioned.
  MODINFO modules.builtin.modinfo
  GEN     modules.builtin
  LD      .tmp_vmlinux.btf
aarch64-linux-gnu-ld: drivers/mmc/core/pwrseq.o: relocation R_AARCH64_ABS32 against `__crc_mmc_pwrseq_register' can not be used when making a shared object
drivers/mmc/core/pwrseq.o:(__patchable_function_entries+0x0): dangerous relocation: unsupported relocation
drivers/mmc/core/pwrseq.o:(__patchable_function_entries+0x8): dangerous relocation: unsupported relocation
drivers/mmc/core/pwrseq.o:(__patchable_function_entries+0x10): dangerous relocation: unsupported relocation
drivers/mmc/core/pwrseq.o:(__patchable_function_entries+0x18): dangerous relocation: unsupported relocation
drivers/mmc/core/pwrseq.o:(__patchable_function_entries+0x20): dangerous relocation: unsupported relocation
drivers/mmc/core/pwrseq.o:(__patchable_function_entries+0x28): dangerous relocation: unsupported relocation
drivers/mmc/core/pwrseq.o:(__patchable_function_entries+0x30): dangerous relocation: unsupported relocation
drivers/mmc/core/pwrseq.o:(__patchable_function_entries+0x38): dangerous relocation: unsupported relocation
  BTF     .btf.vmlinux.bin.o
pahole: .tmp_vmlinux.btf: Invalid argument
  LD      .tmp_vmlinux.kallsyms1
.btf.vmlinux.bin.o: file not recognized: file format not recognized
make[1]: *** [/home/xxx/linux/Makefile:1207: vmlinux] Error 1
make: *** [../Makefile:192: __sub-make] Error 2
FAILED: vmlinux 
cat Makefile | sed -e '/^$(vmlinux-dirs)/,+1d' | make -f - all
ninja: build stopped: subcommand failed.

from that point just running make again fails the build too, modifying the c file again and running make fixes it -- a cursory look with make V=1 shows it's apparently missing the genksyms step which modifies the .o file in place (sigh...):

  if aarch64-linux-gnu-objdump -h drivers/mmc/core/pwrseq.o | grep -q __ksymtab; then aarch64-linux-gnu-gcc -E -D__GENKSYMS__ -Wp,-MMD,drivers/mmc/core/.pwrseq.o.d -nostdinc -isystem /usr/lib/gcc-cross/aarch64-linux-gnu/12/include -I../arch/arm64/include -I./arch/arm64/include/generated -I../include -I./include -I../arch/arm64/include/uapi -I./arch/arm64/include/generated/uapi -I../include/uapi -I./include/generated/uapi -include ../include/linux/kconfig.h -include ../include/linux/compiler_types.h -D__KERNEL__ -mlittle-endian -DCC_USING_PATCHABLE_FUNCTION_ENTRY -DKASAN_SHADOW_SCALE_SHIFT=3 -fmacro-prefix-map=../= -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-type -Wno-format-security -std=gnu89 -mgeneral-regs-only -DCONFIG_CC_HAS_K_CONSTRAINT=1 -Wno-psabi -mabi=lp64 -fno-asynchronous-unwind-tables -fno-unwind-tables -mbranch-protection=pac-ret+leaf -Wa,-march=armv8.4-a -DARM64_ASM_ARCH='"armv8.4-a"' -DKASAN_SHADOW_SCALE_SHIFT=3 -fno-delete-null-pointer-checks -Wno-frame-address -Wno-format-truncation -Wno-format-overflow -Wno-address-of-packed-member -O2 -fno-allow-store-data-races -Wframe-larger-than=2048 -fstack-protector-strong -Wimplicit-fallthrough -Wno-unused-but-set-variable -Wno-unused-const-variable -Wno-dangling-pointer -fno-omit-frame-pointer -fno-optimize-sibling-calls -ftrivial-auto-var-init=zero -g -fpatchable-function-entry=2 -Wdeclaration-after-statement -Wvla -Wno-pointer-sign -Wno-stringop-truncation -Wno-zero-length-bounds -Wno-array-bounds -Wno-stringop-overflow -Wno-restrict -Wno-maybe-uninitialized -fno-strict-overflow -fno-stack-check -fconserve-stack -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -Wno-packed-not-aligned -mstack-protector-guard=sysreg -mstack-protector-guard-reg=sp_el0 -mstack-protector-guard-offset=1168 -I ../drivers/mmc/core -I ./drivers/mmc/core    -DKBUILD_MODFILE='"drivers/mmc/core/mmc_core"' -DKBUILD_BASENAME='"pwrseq"' -DKBUILD_MODNAME='"mmc_core"' ../drivers/mmc/core/pwrseq.c | scripts/genksyms/genksyms    -r /dev/null > drivers/mmc/core/.tmp_pwrseq.ver; aarch64-linux-gnu-ld -EL  -maarch64elf -z noexecstack --no-warn-rwx-segments -r -o drivers/mmc/core/.tmp_pwrseq.o drivers/mmc/core/pwrseq.o -T drivers/mmc/core/.tmp_pwrseq.ver; mv -f drivers/mmc/core/.tmp_pwrseq.o drivers/mmc/core/pwrseq.o; rm -f drivers/mmc/core/.tmp_pwrseq.ver; fi

Anyway, that quick fix wasn't enough so I won't open a PR and will just stop here, but it's worth a shot depending on your exact config.

@vitkyrka great idea to just parse make -p output, if someone has a bit of time I think it'd definitely be useful to brush this up again! Thank you!

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

2 participants