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

making linux 4.9 with some config file, failed, but when invoke gcc it works (which failed to compiling before). #1526

Closed
huawei-nos opened this issue Dec 21, 2016 · 9 comments

Comments

@huawei-nos
Copy link

Please use the following bug reporting template to help produce actionable and reproducible issues. Please try to ensure that the reproduction is minimal so that the team can go through more bugs!

  • A brief description
    making linux 4.9 with some config file, failed, but when invoke gcc it works (which failed to compiling before).
  • Expected results
    making linux kernel should be all right, for it need gcc only,
  • Actual results (with terminal output if applicable)
    "x86_64" "y" "y" "gcc -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Wno-format-security -std=gnu89 -fno-PIE -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -m64 -falign-jumps=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -march=core2 -mno-red-zone -mcmodel=kernel -funit-at-a-time -maccumulate-outgoing-args -DCONFIG_X86_X32_ABI -DCONFIG_AS_CFI=1 -DCONFIG_AS_CFI_SIGNAL_FRAME=1 -DCONFIG_AS_CFI_SECTIONS=1 -DCONFIG_AS_FXSAVEQ=1 -DCONFIG_AS_SSSE3=1 -DCONFIG_AS_CRC32=1 -DCONFIG_AS_AVX=1 -DCONFIG_AS_AVX2=1 -DCONFIG_AS_SHA1_NI=1 -DCONFIG_AS_SHA256_NI=1 -pipe -Wno-sign-compare -fno-asynchronous-unwind-tables -fno-delete-null-pointer-checks -O2 -Wno-maybe-uninitialized --param=allow-store-data-races=0 -Wframe-larger-than=2048 -fno-stack-protector -Wno-unused-but-set-variable -fno-omit-frame-pointer -fno-optimize-sibling-calls -fno-var-tracking-assignments -g -pg -mfentry -DCC_USING_FENTRY -Wdeclaration-after-statement -Wno-pointer-sign -fno-strict-overflow -fconserve-stack -Werror=implicit-int -Werror=strict-prototypes -DCC_HAVE_ASM_GOTO "
    SKIPPED include/generated/compile.h
    gcc -Wp,-MD,init/.version.o.d -nostdinc -isystem /usr/lib/gcc/x86_64-linux-gnu/4.8/include -I/mnt/d/workfolder/kernel/linux/arch/x86/include -I./arch/x86/include/generated/uapi -I./arch/x86/include/generated -I/mnt/d/workfolder/kernel/linux/include -I./include -I/mnt/d/workfolder/kernel/linux/arch/x86/include/uapi -I/mnt/d/workfolder/kernel/linux/include/uapi -I./include/generated/uapi -include /mnt/d/workfolder/kernel/linux/include/linux/kconfig.h -I/mnt/d/workfolder/kernel/linux/init -Iinit -D__KERNEL__ -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Wno-format-security -std=gnu89 -fno-PIE -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -m64 -falign-jumps=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -march=core2 -mno-red-zone -mcmodel=kernel -funit-at-a-time -maccumulate-outgoing-args -DCONFIG_X86_X32_ABI -DCONFIG_AS_CFI=1 -DCONFIG_AS_CFI_SIGNAL_FRAME=1 -DCONFIG_AS_CFI_SECTIONS=1 -DCONFIG_AS_FXSAVEQ=1 -DCONFIG_AS_SSSE3=1 -DCONFIG_AS_CRC32=1 -DCONFIG_AS_AVX=1 -DCONFIG_AS_AVX2=1 -DCONFIG_AS_SHA1_NI=1 -DCONFIG_AS_SHA256_NI=1 -pipe -Wno-sign-compare -fno-asynchronous-unwind-tables -fno-delete-null-pointer-checks -O2 -Wno-maybe-uninitialized --param=allow-store-data-races=0 -Wframe-larger-than=2048 -fno-stack-protector -Wno-unused-but-set-variable -fno-omit-frame-pointer -fno-optimize-sibling-calls -fno-var-tracking-assignments -g -pg -mfentry -DCC_USING_FENTRY -Wdeclaration-after-statement -Wno-pointer-sign -fno-strict-overflow -fconserve-stack -Werror=implicit-int -Werror=strict-prototypes -DCC_HAVE_ASM_GOTO -fno-function-sections -fno-data-sections -DKBUILD_BASENAME='"version"' -DKBUILD_MODNAME='"version"' -c -o init/version.o /mnt/d/workfolder/kernel/linux/init/version.c
    if [ "-pg" = "-pg" ]; then if [ init/version.o != "scripts/mod/empty.o" ]; then ./scripts/recordmcount "init/version.o"; fi; fi;
    gcc -Wp,-MD,init/.do_mounts.o.d -nostdinc -isystem /usr/lib/gcc/x86_64-linux-gnu/4.8/include -I/mnt/d/workfolder/kernel/linux/arch/x86/include -I./arch/x86/include/generated/uapi -I./arch/x86/include/generated -I/mnt/d/workfolder/kernel/linux/include -I./include -I/mnt/d/workfolder/kernel/linux/arch/x86/include/uapi -I/mnt/d/workfolder/kernel/linux/include/uapi -I./include/generated/uapi -include /mnt/d/workfolder/kernel/linux/include/linux/kconfig.h -I/mnt/d/workfolder/kernel/linux/init -Iinit -D__KERNEL__ -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Wno-format-security -std=gnu89 -fno-PIE -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -m64 -falign-jumps=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -march=core2 -mno-red-zone -mcmodel=kernel -funit-at-a-time -maccumulate-outgoing-args -DCONFIG_X86_X32_ABI -DCONFIG_AS_CFI=1 -DCONFIG_AS_CFI_SIGNAL_FRAME=1 -DCONFIG_AS_CFI_SECTIONS=1 -DCONFIG_AS_FXSAVEQ=1 -DCONFIG_AS_SSSE3=1 -DCONFIG_AS_CRC32=1 -DCONFIG_AS_AVX=1 -DCONFIG_AS_AVX2=1 -DCONFIG_AS_SHA1_NI=1 -DCONFIG_AS_SHA256_NI=1 -pipe -Wno-sign-compare -fno-asynchronous-unwind-tables -fno-delete-null-pointer-checks -O2 -Wno-maybe-uninitialized --param=allow-store-data-races=0 -Wframe-larger-than=2048 -fno-stack-protector -Wno-unused-but-set-variable -fno-omit-frame-pointer -fno-optimize-sibling-calls -fno-var-tracking-assignments -g -pg -mfentry -DCC_USING_FENTRY -Wdeclaration-after-statement -Wno-pointer-sign -fno-strict-overflow -fconserve-stack -Werror=implicit-int -Werror=strict-prototypes -DCC_HAVE_ASM_GOTO -fno-function-sections -fno-data-sections -DKBUILD_BASENAME='"do_mounts"' -DKBUILD_MODNAME='"mounts"' -c -o init/do_mounts.o /mnt/d/workfolder/kernel/linux/init/do_mounts.c
    if [ "-pg" = "-pg" ]; then if [ init/do_mounts.o != "scripts/mod/empty.o" ]; then ./scripts/recordmcount "init/do_mounts.o"; fi; fi;
    init/do_mounts.o: Operation not permitted
    init/do_mounts.o: failed
    make[3]: *** [init/do_mounts.o] Error 1
    make[2]: *** [init] Error 2
    make[1]: *** [sub-make] Error 2
    make: *** [__sub-make] Error 2
  • Your Windows build number
    14393.576
    Microsoft Windows [Version 10.0.14393]
  • Steps / All commands required to reproduce the error from a brand new installation
    download the linux kernel source code from https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.9.tar.xz
    get the kernel config file from centos 7.3 config-3.10.0-514.2.2.el7.x86_64.
    cd linux-4.9
    cp config-3.10.0-514.2.2.el7.x86_64 ./.config
    make menuconfig
    then select exit , when prompted whether to save , select YES.
    last: make V=1
  • Strace of the failing command
    the failed command works well when I run it again, follows:
    zoge@VM1-Z00234794:/workfolder/kernel/build-linux$ gcc -Wp,-MD,init/.do_mounts.o.d -nostdinc -isystem /usr/lib/gcc/x86_64-linux-gnu/4.8/include -I/mnt/d/workfolder/kernel/linux/arch/x86/include -I./arch/x86/include/generated/uapi -I./arch/x86/include/generated -I/mnt/d/workfolder/kernel/linux/include -I./include -I/mnt/d/workfolder/kernel/linux/arch/x86/include/uapi -I/mnt/d/workfolder/kernel/linux/include/uapi -I./include/generated/uapi -include /mnt/d/workfolder/kernel/linux/include/linux/kconfig.h -I/mnt/d/workfolder/kernel/linux/init -Iinit -D__KERNEL__ -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Wno-format-security -std=gnu89 -fno-PIE -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -m64 -falign-jumps=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -march=core2 -mno-red-zone -mcmodel=kernel -funit-at-a-time -maccumulate-outgoing-args -DCONFIG_X86_X32_ABI -DCONFIG_AS_CFI=1 -DCONFIG_AS_CFI_SIGNAL_FRAME=1 -DCONFIG_AS_CFI_SECTIONS=1 -DCONFIG_AS_FXSAVEQ=1 -DCONFIG_AS_SSSE3=1 -DCONFIG_AS_CRC32=1 -DCONFIG_AS_AVX=1 -DCONFIG_AS_AVX2=1 -DCONFIG_AS_SHA1_NI=1 -DCONFIG_AS_SHA256_NI=1 -pipe -Wno-sign-compare -fno-asynchronous-unwind-tables -fno-delete-null-pointer-checks -O2 -Wno-maybe-uninitialized --param=allow-store-data-races=0 -Wframe-larger-than=2048 -fno-stack-protector -Wno-unused-but-set-variable -fno-omit-frame-pointer -fno-optimize-sibling-calls -fno-var-tracking-assignments -g -pg -mfentry -DCC_USING_FENTRY -Wdeclaration-after-statement -Wno-pointer-sign -fno-strict-overflow -fconserve-stack -Werror=implicit-int -Werror=strict-prototypes -DCC_HAVE_ASM_GOTO -fno-function-sections -fno-data-sections -DKBUILD_BASENAME='"do_mounts"' -DKBUILD_MODNAME='"mounts"' -c -o init/do_mounts.o /mnt/d/workfolder/kernel/linux/init/do_mounts.c
    zoge@VM1-Z00234794:
    /workfolder/kernel/build-linux$

the configure file "config-3.10.0-514.2.2.el7.x86_64" can be getted from this rpm file : http://mirror.centos.org/centos/7/updates/x86_64/Packages/kernel-3.10.0-514.2.2.el7.x86_64.rpm

@huawei-nos
Copy link
Author

huawei-nos commented Feb 7, 2017

[pid 11864] rename("init/calibrate.o.rc", "init/calibrate.o") = -1 EPERM (Operation not permitted)

using strace -f make, I get the error .

[pid 11864] close(3) = 0
[pid 11864] brk(0) = 0x1230000
[pid 11864] brk(0x1251000) = 0x1251000
[pid 11864] open("init/calibrate.o.rc", O_WRONLY|O_CREAT|O_TRUNC, 0100777) = 3
[pid 11864] write(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\1\0>\0\1\0\0\0\0\0\0\0\0\0\0\0"..., 35712) = 35712
[pid 11864] write(3, "\0.symtab\0.strtab\0.shstrtab\0.rela"..., 2592) = 2592
[pid 11864] close(3) = 0
[pid 11864] rename("init/calibrate.o.rc", "init/calibrate.o") = -1 EPERM (Operation not permitted)
[pid 11864] dup(2) = 3
[pid 11864] fcntl(3, F_GETFL) = 0x2 (flags O_RDWR)
[pid 11864] fstat(3, {st_mode=S_IFCHR|0600, st_rdev=makedev(4, 1), ...}) = 0
[pid 11864] ioctl(3, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, {B38400 opost isig icanon echo ...}) = 0
[pid 11864] mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fa377580000
[pid 11864] lseek(3, 0, SEEK_CUR) = -1 ESPIPE (Illegal seek)
[pid 11864] write(3, "init/calibrate.o: Operation not "..., 42init/calibrate.o: Operation not permitted
) = 42
[pid 11864] close(3) = 0
[pid 11864] munmap(0x7fa377580000, 4096) = 0
[pid 11864] munmap(0x7fa3775a7000, 35712) = 0
[pid 11864] write(2, "init/calibrate.o: failed\n", 25init/calibrate.o: failed
) = 25
[pid 11864] exit_group(1) = ?
[pid 11864] +++ exited with 1 +++
[pid 11857] <... wait4 resumed> [{WIFEXITED(s) && WEXITSTATUS(s) == 1}], 0, NULL) = 11864

@huawei-nos
Copy link
Author

~/workfolder/kernel/build-linux$ ls -a -l init/calibrate.o.rc init/calibrate.o
-rwxrwxrwx 1 root root 35712 Feb 7 15:04 init/calibrate.o
-rwxrwxrwx 1 root root 38304 Feb 7 15:04 init/calibrate.o.rc

the rename cmd is from windows? has windows translate the mv oper into rename cmd of windows? for linux hasn't the cmd like this.
the target file is existed, so the rename cmd failed.
this is the root cause of the bug?

@huawei-nos
Copy link
Author

#44

from this bug , I change the kernel build folder from windows to ~/( that is : C:\Users\ YOUR_USER_NAME \AppData\Local\Lxss\rootfs), and everything is ok.

@aseering
Copy link
Contributor

aseering commented Feb 7, 2017

Hi @huawei-nos -- I'm glad you found a fix! You might consider trying an Insider build to see if this has been fixed there.

Just so you know, strace doesn't trace commands; it traces syscalls, low-level programmatic function calls into the Linux (or, in this case, WSL) kernel. rename() actually is a Linux syscall.

@huawei-nos
Copy link
Author

yes, you are right, the rename is the syscall and locate at kernel code namei.c
SYSCALL_DEFINE2(rename, const char __user *, oldname, const char __user *, newname)
{
return sys_renameat2(AT_FDCWD, oldname, AT_FDCWD, newname, 0);
}
so the problem is because the oldfile and newfile are all existed, on windows filesystem the syscall return -1.

@huawei-nos
Copy link
Author

but I write a demo prog call rename syscall to rename the two files, no errors even on windows part.
/workfolder is a link to a windows folder
zoge@VM1:
/workfolder/kernel/build-linux$ ls -a -l arch/x86/crypto/glue_helper.o.rc arch/x86/crypto/glue_helper.o
-rwxrwxrwx 1 root root 203336 Feb 8 11:15 arch/x86/crypto/glue_helper.o
-rwxrwxrwx 1 root root 206664 Feb 8 11:15 arch/x86/crypto/glue_helper.o.rc
zoge@VM1-:/workfolder/kernel/build-linux$ ../../test/a.out arch/x86/crypto/glue_helper.o.rc arch/x86/crypto/glue_helper.o
zoge@VM1-:
/workfolder/kernel/build-linux$ ls -a -l arch/x86/crypto/glue_helper.o.rc arch/x86/crypto/glue_helper.o
ls: cannot access arch/x86/crypto/glue_helper.o.rc: No such file or directory
-rwxrwxrwx 1 root root 206664 Feb 8 11:15 arch/x86/crypto/glue_helper.o
I have no ideas about this bug.

   #define _GNU_SOURCE
   #include <unistd.h>
   #include <sys/syscall.h>
   #include <sys/types.h>
   #include <signal.h>

   int
   main(int argc, char *argv[])
   {
       int iret;

       //tid = syscall(SYS_gettid);
       iret = syscall(SYS_rename, argv[1], argv[2]);

       return  iret;
   }

@aseering
Copy link
Contributor

aseering commented Feb 8, 2017

One thought: Regular Windows NTFS is case-insensitive, but most Linux filesystems are case-sensitive. Could it be that the kernel build system is trying to create two separate files that have names that are the same except for capitalization?

@huawei-nos
Copy link
Author

zoge@VM1-:~/workfolder/kernel/build-linux$ ls -a -l ~/workfolder
lrwxrwxrwx 1 zoge zoge 17 Nov 26 10:03 /home/zoge/workfolder -> /mnt/d/workfolder

zoge@VM1-:/workfolder/kernel/build-linux$ touch AAA
zoge@VM1-:
/workfolder/kernel/build-linux$ touch aaa
zoge@VM1-:~/workfolder/kernel/build-linux$ ls -a -l
total 333
drwxrwxrwx 2 root root 0 Feb 8 15:23 .
drwxrwxrwx 2 root root 0 Dec 27 10:39 ..
-rwxrwxrwx 1 root root 0 Feb 8 15:23 aaa
-rwxrwxrwx 1 root root 0 Feb 8 15:23 AAA

from above , it sames like that even on ntfs part, bash on windows can recognize the aaa adnd AAA file.

see my posts above, the error I getted from strace is
[pid 11864] rename("init/calibrate.o.rc", "init/calibrate.o") = -1 EPERM (Operation not permitted)
init/calibrate.o.rc and init/calibrate.o existed and have different size,

first I thought the bug is because the target file exist and ntfs cannot permit the oper.

but I run a demo to call linux's syscall rename to retry the oper, it succeeds.

but if I delete all the two files and rebuild the kernel, the error existed again.
it is strange that why call rename directly pass but failed when build linux kernel.

@huawei-nos
Copy link
Author

mv the kernel build to ~/build-linux, the rename is called also , when build the kernel, but this time it is ok!

[pid 9899] rename("arch/x86/crypto/glue_helper.o.rc", "arch/x86/crypto/glue_helper.o") = 0
[pid 9899] munmap(0x7f7c258de000, 203312) = 0
[pid 9899] exit_group(0) = ?
[pid 9899] +++ exited with 0 +++

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