我从源代码安装了gcc 8.3.0。
如果我将gcc与完整路径一起使用,则效果很好。
$ /usr/bin/gcc test.c
但是,如果我使用不带完整路径的gcc,则会导致错误:
$ gcc test.c
gcc: error trying to exec 'cc1': execvp: No such file or directory
我可以解决此问题吗?还是此gcc特定(必须使用完整路径)?
样本来源:
//test.c or test.cpp
void main(){}
没有完整路径的跟踪(错误:1):
execve("/bin/sh", ["/bin/sh", "-c", "gcc test.cpp -Wno-write-st"...], 0xbfbb4e68 /* 14 vars */) = 0
set_thread_area({entry_number=-1, base_addr=0x814816c, limit=0x0fffff, seg_32bit=1, contents=0, read_exec_only=0, limit_in_pages=1, seg_not_present=0, useable=1}) = 0 (entry_number=6)
set_tid_address(0x81489ec) = 16010
getuid32() = 0
brk(NULL) = 0x8cee000
brk(0x8cef000) = 0x8cef000
getpid() = 16010
rt_sigprocmask(SIG_UNBLOCK, [RT_1 RT_2], NULL, 8) = 0
rt_sigaction(SIGCHLD, {sa_handler=0x80bee30, sa_mask=~[RTMIN RT_1 RT_2], sa_flags=SA_RESTORER, sa_restorer=0x8114571}, NULL, 8) = 0
rt_sigaction(SIGHUP, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x8114571}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
brk(0x8cf0000) = 0x8cf0000
getppid() = 16007
uname({sysname="Linux", nodename="DESLX", ...}) = 0
stat64("/tmp/linux-test", {st_mode=S_IFDIR|0755, st_size=260, ...}) = 0
stat64(".", {st_mode=S_IFDIR|0755, st_size=260, ...}) = 0
rt_sigaction(SIGINT, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGINT, {sa_handler=0x80bee30, sa_mask=~[RTMIN RT_1 RT_2], sa_flags=SA_RESTORER, sa_restorer=0x8114571}, NULL, 8) = 0
rt_sigaction(SIGQUIT, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGQUIT, {sa_handler=SIG_IGN, sa_mask=~[RTMIN RT_1 RT_2], sa_flags=SA_RESTORER, sa_restorer=0x8114571}, NULL, 8) = 0
rt_sigaction(SIGTERM, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
stat64("/sbin/gcc", 0xbf92665c) = -1 ENOENT (No such file or directory)
stat64("/usr/sbin/gcc", 0xbf92665c) = -1 ENOENT (No such file or directory)
stat64("/bin/gcc", 0xbf92665c) = -1 ENOENT (No such file or directory)
stat64("/usr/bin/gcc", {st_mode=S_IFREG|0755, st_size=1490096, ...}) = 0
execve("/usr/bin/gcc", ["gcc", "test.cpp", "-Wno-write-strings"], 0x8cee314 /* 14 vars */) = 0
set_thread_area({entry_number=-1, base_addr=0x8177bf4, limit=0x0fffff, seg_32bit=1, contents=0, read_exec_only=0, limit_in_pages=1, seg_not_present=0, useable=1}) = 0 (entry_number=6)
set_tid_address(0x8177dc8) = 16010
brk(NULL) = 0x853b000
brk(0x853c000) = 0x853c000
brk(NULL) = 0x853c000
brk(0x853e000) = 0x853e000
brk(0x854f000) = 0x854f000
brk(0x8550000) = 0x8550000
ioctl(2, TIOCGWINSZ, 0xbfd450f8) = -1 EINVAL (Invalid argument)
ioctl(2, TIOCGWINSZ, 0xbfd450f8) = -1 EINVAL (Invalid argument)
rt_sigaction(SIGINT, {sa_handler=SIG_IGN, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x80d9557}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [RT_1 RT_2], NULL, 8) = 0
rt_sigaction(SIGINT, {sa_handler=0x804cc90, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x80d9557}, {sa_handler=SIG_IGN, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x80d9557}, 8) = 0
rt_sigaction(SIGHUP, {sa_handler=SIG_IGN, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x80d9557}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGHUP, {sa_handler=0x804cc90, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x80d9557}, {sa_handler=SIG_IGN, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x80d9557}, 8) = 0
rt_sigaction(SIGTERM, {sa_handler=SIG_IGN, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x80d9557}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGTERM, {sa_handler=0x804cc90, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x80d9557}, {sa_handler=SIG_IGN, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x80d9557}, 8) = 0
rt_sigaction(SIGPIPE, {sa_handler=SIG_IGN, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x80d9557}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGPIPE, {sa_handler=0x804cc90, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x80d9557}, {sa_handler=SIG_IGN, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x80d9557}, 8) = 0
rt_sigaction(SIGCHLD, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x80d9557}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
prlimit64(0, RLIMIT_STACK, NULL, {rlim_cur=8192*1024, rlim_max=RLIM64_INFINITY}) = 0
rt_sigprocmask(SIG_BLOCK, ~[RTMIN RT_1 RT_2], [], 8) = 0
rt_sigprocmask(SIG_BLOCK, ~[], NULL, 8) = 0
prlimit64(0, RLIMIT_STACK, {rlim_cur=65536*1024, rlim_max=RLIM64_INFINITY}, NULL) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
brk(0x8551000) = 0x8551000
brk(0x8552000) = 0x8552000
open("gcc", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_CLOEXEC|O_PATH) = -1 ENOENT (No such file or directory)
open("gcc", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_CLOEXEC|O_PATH) = -1 ENOENT (No such file or directory)
access("test.cpp", F_OK) = 0
access("../lib/gcc/i686-test-linux/8.3.0/", X_OK) = -1 ENOENT (No such file or directory)
access("../lib/gcc/i686-test-linux/", X_OK) = -1 ENOENT (No such file or directory)
access("../lib/gcc/", X_OK) = -1 ENOENT (No such file or directory)
access("../lib/", X_OK) = -1 ENOENT (No such file or directory)
access("../lib/gcc/i686-test-linux/8.3.0/", X_OK) = -1 ENOENT (No such file or directory)
access("../lib/gcc/i686-test-linux/", X_OK) = -1 ENOENT (No such file or directory)
access("../lib/gcc/", X_OK) = -1 ENOENT (No such file or directory)
access("../lib/", X_OK) = -1 ENOENT (No such file or directory)
open("gcc", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_CLOEXEC|O_PATH) = -1 ENOENT (No such file or directory)
brk(0x8553000) = 0x8553000
access("../../usr", F_OK) = 0
access("../lib/gcc/i686-test-linux/8.3.0/specs", R_OK) = -1 ENOENT (No such file or directory)
access("../lib/gcc/specs", R_OK) = -1 ENOENT (No such file or directory)
access("../i686-test-linux/lib/i686-test-linux/8.3.0/specs", R_OK) = -1 ENOENT (No such file or directory)
access("../i686-test-linux/lib/specs", R_OK) = -1 ENOENT (No such file or directory)
access("/usr/lib/gcc/i686-test-linux/specs", R_OK) = -1 ENOENT (No such file or directory)
access("../lib/gcc/i686-test-linux/8.3.0/", X_OK) = -1 ENOENT (No such file or directory)
access("../lib/gcc/i686-test-linux/", X_OK) = -1 ENOENT (No such file or directory)
access("../lib/gcc/", X_OK) = -1 ENOENT (No such file or directory)
access("../", X_OK) = 0
access("../", X_OK) = 0
brk(0x8554000) = 0x8554000
stat64("../libexec/gcc/i686-test-linux/8.3.0/lto-wrapper", 0xbfd44ff0) = -1 ENOENT (No such file or directory)
stat64("../libexec/gcc/lto-wrapper", 0xbfd44ff0) = -1 ENOENT (No such file or directory)
stat64("../i686-test-linux/bin/i686-test-linux/8.3.0/lto-wrapper", 0xbfd44ff0) = -1 ENOENT (No such file or directory)
stat64("../i686-test-linux/bin/lto-wrapper", 0xbfd44ff0) = -1 ENOENT (No such file or directory)
access("/tmp", R_OK|W_OK|X_OK) = 0
clock_gettime(CLOCK_REALTIME, {tv_sec=1561737190, tv_nsec=72258100}) = 0
open("/tmp/ccKGEANB.s", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE, 0600) = 3
close(3) = 0
stat64("../libexec/gcc/i686-test-linux/8.3.0/cc1plus", 0xbfd44660) = -1 ENOENT (No such file or directory)
stat64("../libexec/gcc/cc1plus", 0xbfd44660) = -1 ENOENT (No such file or directory)
stat64("../i686-test-linux/bin/i686-test-linux/8.3.0/cc1plus", 0xbfd44660) = -1 ENOENT (No such file or directory)
stat64("../i686-test-linux/bin/cc1plus", 0xbfd44660) = -1 ENOENT (No such file or directory)
vfork(gcc: error trying to exec 'cc1plus': execvp: No such file or directory
) = 16011
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=16011, si_uid=0, si_status=255, si_utime=0, si_stime=0} ---
wait4(16011, [{WIFEXITED(s) && WEXITSTATUS(s) == 255}], 0, NULL) = 16011
stat64("/tmp/ccKGEANB.s", {st_mode=S_IFREG|0600, st_size=0, ...}) = 0
unlink("/tmp/ccKGEANB.s") = 0
exit_group(1) = ?
+++ exited with 1 +++
具有完整路径的跟踪(错误:0):
execve("/bin/sh", ["/bin/sh", "-c", "/usr/bin/gcc test.cpp -Wno"...], 0xbffa0bc8 /* 14 vars */) = 0
set_thread_area({entry_number=-1, base_addr=0x814816c, limit=0x0fffff, seg_32bit=1, contents=0, read_exec_only=0, limit_in_pages=1, seg_not_present=0, useable=1}) = 0 (entry_number=6)
set_tid_address(0x81489ec) = 16029
getuid32() = 0
brk(NULL) = 0x8f18000
brk(0x8f19000) = 0x8f19000
getpid() = 16029
rt_sigprocmask(SIG_UNBLOCK, [RT_1 RT_2], NULL, 8) = 0
rt_sigaction(SIGCHLD, {sa_handler=0x80bee30, sa_mask=~[RTMIN RT_1 RT_2], sa_flags=SA_RESTORER, sa_restorer=0x8114571}, NULL, 8) = 0
rt_sigaction(SIGHUP, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x8114571}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
brk(0x8f1a000) = 0x8f1a000
getppid() = 16026
uname({sysname="Linux", nodename="DESLX", ...}) = 0
stat64("/tmp/linux-test", {st_mode=S_IFDIR|0755, st_size=260, ...}) = 0
stat64(".", {st_mode=S_IFDIR|0755, st_size=260, ...}) = 0
rt_sigaction(SIGINT, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGINT, {sa_handler=0x80bee30, sa_mask=~[RTMIN RT_1 RT_2], sa_flags=SA_RESTORER, sa_restorer=0x8114571}, NULL, 8) = 0
rt_sigaction(SIGQUIT, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGQUIT, {sa_handler=SIG_IGN, sa_mask=~[RTMIN RT_1 RT_2], sa_flags=SA_RESTORER, sa_restorer=0x8114571}, NULL, 8) = 0
rt_sigaction(SIGTERM, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
execve("/usr/bin/gcc", ["/usr/bin/gcc", "test.cpp", "-Wno-write-strings"], 0x8f1832c /* 14 vars */) = 0
set_thread_area({entry_number=-1, base_addr=0x8177bf4, limit=0x0fffff, seg_32bit=1, contents=0, read_exec_only=0, limit_in_pages=1, seg_not_present=0, useable=1}) = 0 (entry_number=6)
set_tid_address(0x8177dc8) = 16029
brk(NULL) = 0x986d000
brk(0x986e000) = 0x986e000
brk(NULL) = 0x986e000
brk(0x9870000) = 0x9870000
brk(0x9881000) = 0x9881000
brk(0x9882000) = 0x9882000
ioctl(2, TIOCGWINSZ, 0xbfec0478) = -1 EINVAL (Invalid argument)
ioctl(2, TIOCGWINSZ, 0xbfec0478) = -1 EINVAL (Invalid argument)
rt_sigaction(SIGINT, {sa_handler=SIG_IGN, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x80d9557}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [RT_1 RT_2], NULL, 8) = 0
rt_sigaction(SIGINT, {sa_handler=0x804cc90, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x80d9557}, {sa_handler=SIG_IGN, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x80d9557}, 8) = 0
rt_sigaction(SIGHUP, {sa_handler=SIG_IGN, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x80d9557}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGHUP, {sa_handler=0x804cc90, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x80d9557}, {sa_handler=SIG_IGN, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x80d9557}, 8) = 0
rt_sigaction(SIGTERM, {sa_handler=SIG_IGN, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x80d9557}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGTERM, {sa_handler=0x804cc90, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x80d9557}, {sa_handler=SIG_IGN, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x80d9557}, 8) = 0
rt_sigaction(SIGPIPE, {sa_handler=SIG_IGN, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x80d9557}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGPIPE, {sa_handler=0x804cc90, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x80d9557}, {sa_handler=SIG_IGN, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x80d9557}, 8) = 0
rt_sigaction(SIGCHLD, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x80d9557}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
prlimit64(0, RLIMIT_STACK, NULL, {rlim_cur=8192*1024, rlim_max=RLIM64_INFINITY}) = 0
rt_sigprocmask(SIG_BLOCK, ~[RTMIN RT_1 RT_2], [], 8) = 0
rt_sigprocmask(SIG_BLOCK, ~[], NULL, 8) = 0
prlimit64(0, RLIMIT_STACK, {rlim_cur=65536*1024, rlim_max=RLIM64_INFINITY}, NULL) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
brk(0x9883000) = 0x9883000
brk(0x9884000) = 0x9884000
open("/usr/bin/gcc", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_CLOEXEC|O_PATH) = 3
readlink("/proc/self/fd/3", "/usr/bin/gcc", 4095) = 12
fstat64(3, {st_mode=S_IFREG|0755, st_size=1490096, ...}) = 0
stat64("/usr/bin/gcc", {st_mode=S_IFREG|0755, st_size=1490096, ...}) = 0
close(3) = 0
open("/usr/bin/gcc", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_CLOEXEC|O_PATH) = 3
readlink("/proc/self/fd/3", "/usr/bin/gcc", 4095) = 12
fstat64(3, {st_mode=S_IFREG|0755, st_size=1490096, ...}) = 0
stat64("/usr/bin/gcc", {st_mode=S_IFREG|0755, st_size=1490096, ...}) = 0
close(3) = 0
access("test.cpp", F_OK) = 0
access("/usr/lib/gcc/i686-test-linux/8.3.0/", X_OK) = 0
access("/usr/lib/gcc/i686-test-linux/8.3.0/", X_OK) = 0
brk(0x9885000) = 0x9885000
access("/usr/lib/gcc/i686-test-linux/8.3.0/specs", R_OK) = -1 ENOENT (No such file or directory)
access("/usr/lib/gcc/i686-test-linux/8.3.0/../../../../i686-test-linux/lib/i686-test-linux/8.3.0/specs", R_OK) = -1 ENOENT (No such file or directory)
access("/usr/lib/gcc/i686-test-linux/8.3.0/../../../../i686-test-linux/lib/specs", R_OK) = -1 ENOENT (No such file or directory)
access("/usr/lib/gcc/i686-test-linux/specs", R_OK) = -1 ENOENT (No such file or directory)
access("/usr/lib/gcc/i686-test-linux/8.3.0/", X_OK) = 0
brk(0x9886000) = 0x9886000
stat64("/usr/libexec/gcc/i686-test-linux/8.3.0/lto-wrapper", {st_mode=S_IFREG|0755, st_size=1397652, ...}) = 0
access("/usr/libexec/gcc/i686-test-linux/8.3.0/lto-wrapper", X_OK) = 0
brk(0x9887000) = 0x9887000
access("/tmp", R_OK|W_OK|X_OK) = 0
clock_gettime(CLOCK_REALTIME, {tv_sec=1561737208, tv_nsec=84838200}) = 0
open("/tmp/ccoIKDmM.s", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE, 0600) = 3
close(3) = 0
stat64("/usr/libexec/gcc/i686-test-linux/8.3.0/cc1plus", {st_mode=S_IFREG|0755, st_size=30230160, ...}) = 0
access("/usr/libexec/gcc/i686-test-linux/8.3.0/cc1plus", X_OK) = 0
vfork() = 16030
wait4(16030, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0, NULL) = 16030
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=16030, si_uid=0, si_status=0, si_utime=38, si_stime=3} ---
clock_gettime(CLOCK_REALTIME, {tv_sec=1561737208, tv_nsec=558595000}) = 0
open("/tmp/ccaIfIIE.o", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE, 0600) = 3
close(3) = 0
stat64("/usr/libexec/gcc/i686-test-linux/8.3.0/as", 0xbfec0280) = -1 ENOENT (No such file or directory)
stat64("/usr/libexec/gcc/i686-test-linux/8.3.0/as", 0xbfec0280) = -1 ENOENT (No such file or directory)
stat64("/usr/libexec/gcc/i686-test-linux/as", 0xbfec0280) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/gcc/i686-test-linux/8.3.0/as", 0xbfec0280) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/gcc/i686-test-linux/as", 0xbfec0280) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/gcc/i686-test-linux/8.3.0/../../../../i686-test-linux/bin/i686-test-linux/8.3.0/as", 0xbfec0280) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/gcc/i686-test-linux/8.3.0/../../../../i686-test-linux/bin/as", {st_mode=S_IFREG|0755, st_size=1780284, ...}) = 0
access("/usr/lib/gcc/i686-test-linux/8.3.0/../../../../i686-test-linux/bin/as", X_OK) = 0
vfork() = 16031
wait4(16031, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0, NULL) = 16031
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=16031, si_uid=0, si_status=0, si_utime=1, si_stime=0} ---
stat64("/usr/libexec/gcc/i686-test-linux/8.3.0/collect2", {st_mode=S_IFREG|0755, st_size=1058760, ...}) = 0
access("/usr/libexec/gcc/i686-test-linux/8.3.0/collect2", X_OK) = 0
stat64("/usr/libexec/gcc/i686-test-linux/8.3.0/.", {st_mode=S_IFDIR|0777, st_size=4096, ...}) = 0
stat64("/usr/libexec/gcc/i686-test-linux/8.3.0/.", {st_mode=S_IFDIR|0777, st_size=4096, ...}) = 0
stat64("/usr/libexec/gcc/i686-test-linux/.", {st_mode=S_IFDIR|0777, st_size=0, ...}) = 0
stat64("/usr/lib/gcc/i686-test-linux/8.3.0/.", {st_mode=S_IFDIR|0777, st_size=4096, ...}) = 0
stat64("/usr/lib/gcc/i686-test-linux/.", {st_mode=S_IFDIR|0777, st_size=0, ...}) = 0
stat64("/usr/lib/gcc/i686-test-linux/8.3.0/../../../../i686-test-linux/bin/i686-test-linux/8.3.0/.", 0xbfec0360) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/gcc/i686-test-linux/8.3.0/../../../../i686-test-linux/bin/.", {st_mode=S_IFDIR|0777, st_size=4096, ...}) = 0
stat64("/usr/lib/gcc/i686-test-linux/8.3.0/.", {st_mode=S_IFDIR|0777, st_size=4096, ...}) = 0
stat64("/usr/lib/gcc/i686-test-linux/8.3.0/../../../../i686-test-linux/lib/i686-test-linux/8.3.0/.", 0xbfec0360) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/gcc/i686-test-linux/8.3.0/../../../../i686-test-linux/lib/.", {st_mode=S_IFDIR|0777, st_size=0, ...}) = 0
stat64("/usr/lib/gcc/i686-test-linux/8.3.0/../../../i686-test-linux/8.3.0/.", 0xbfec0360) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/gcc/i686-test-linux/8.3.0/../../../.", {st_mode=S_IFDIR|0777, st_size=24576, ...}) = 0
stat64("/usr/lib/i686-test-linux/8.3.0/.", 0xbfec0360) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/.", {st_mode=S_IFDIR|0777, st_size=24576, ...}) = 0
stat64("/usr/usr/lib/i686-test-linux/8.3.0/.", 0xbfec0360) = -1 ENOENT (No such file or directory)
stat64("/usr/usr/lib/.", 0xbfec0360) = -1 ENOENT (No such file or directory)
brk(0x9888000) = 0x9888000
brk(0x9889000) = 0x9889000
brk(0x988a000) = 0x988a000
brk(0x988b000) = 0x988b000
brk(0x988c000) = 0x988c000
access("/usr/lib/gcc/i686-test-linux/8.3.0/crt1.o", R_OK) = -1 ENOENT (No such file or directory)
access("/usr/lib/gcc/i686-test-linux/8.3.0/../../../../i686-test-linux/lib/i686-test-linux/8.3.0/crt1.o", R_OK) = -1 ENOENT (No such file or directory)
access("/usr/lib/gcc/i686-test-linux/8.3.0/../../../../i686-test-linux/lib/crt1.o", R_OK) = -1 ENOENT (No such file or directory)
access("/usr/lib/gcc/i686-test-linux/8.3.0/../../../i686-test-linux/8.3.0/crt1.o", R_OK) = -1 ENOENT (No such file or directory)
access("/usr/lib/gcc/i686-test-linux/8.3.0/../../../crt1.o", R_OK) = 0
access("/usr/lib/gcc/i686-test-linux/8.3.0/crti.o", R_OK) = -1 ENOENT (No such file or directory)
access("/usr/lib/gcc/i686-test-linux/8.3.0/../../../../i686-test-linux/lib/i686-test-linux/8.3.0/crti.o", R_OK) = -1 ENOENT (No such file or directory)
access("/usr/lib/gcc/i686-test-linux/8.3.0/../../../../i686-test-linux/lib/crti.o", R_OK) = -1 ENOENT (No such file or directory)
access("/usr/lib/gcc/i686-test-linux/8.3.0/../../../i686-test-linux/8.3.0/crti.o", R_OK) = -1 ENOENT (No such file or directory)
access("/usr/lib/gcc/i686-test-linux/8.3.0/../../../crti.o", R_OK) = 0
access("/usr/lib/gcc/i686-test-linux/8.3.0/crtbegin.o", R_OK) = 0
stat64("/usr/lib/gcc/i686-test-linux/8.3.0/.", {st_mode=S_IFDIR|0777, st_size=4096, ...}) = 0
stat64("/usr/lib/gcc/i686-test-linux/8.3.0/../../../../i686-test-linux/lib/i686-test-linux/8.3.0/.", 0xbfebfb00) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/gcc/i686-test-linux/8.3.0/../../../../i686-test-linux/lib/.", {st_mode=S_IFDIR|0777, st_size=0, ...}) = 0
stat64("/usr/lib/gcc/i686-test-linux/8.3.0/../../../i686-test-linux/8.3.0/.", 0xbfebfb00) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/gcc/i686-test-linux/8.3.0/../../../.", {st_mode=S_IFDIR|0777, st_size=24576, ...}) = 0
stat64("/usr/lib/i686-test-linux/8.3.0/.", 0xbfebfb00) = -1 ENOENT (No such file or directory)
stat64("/usr/usr/lib/i686-test-linux/8.3.0/.", 0xbfebfb00) = -1 ENOENT (No such file or directory)
stat64("/usr/usr/lib/.", 0xbfebfb00) = -1 ENOENT (No such file or directory)
access("/usr/lib/gcc/i686-test-linux/8.3.0/crtend.o", R_OK) = 0
access("/usr/lib/gcc/i686-test-linux/8.3.0/crtn.o", R_OK) = -1 ENOENT (No such file or directory)
access("/usr/lib/gcc/i686-test-linux/8.3.0/../../../../i686-test-linux/lib/i686-test-linux/8.3.0/crtn.o", R_OK) = -1 ENOENT (No such file or directory)
access("/usr/lib/gcc/i686-test-linux/8.3.0/../../../../i686-test-linux/lib/crtn.o", R_OK) = -1 ENOENT (No such file or directory)
access("/usr/lib/gcc/i686-test-linux/8.3.0/../../../i686-test-linux/8.3.0/crtn.o", R_OK) = -1 ENOENT (No such file or directory)
access("/usr/lib/gcc/i686-test-linux/8.3.0/../../../crtn.o", R_OK) = 0
stat64("/usr/libexec/gcc/i686-test-linux/8.3.0/collect2", {st_mode=S_IFREG|0755, st_size=1058760, ...}) = 0
access("/usr/libexec/gcc/i686-test-linux/8.3.0/collect2", X_OK) = 0
vfork() = 16032
wait4(16032, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0, NULL) = 16032
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=16032, si_uid=0, si_status=0, si_utime=0, si_stime=0} ---
stat64("/tmp/ccaIfIIE.o", {st_mode=S_IFREG|0600, st_size=175096, ...}) = 0
unlink("/tmp/ccaIfIIE.o") = 0
stat64("/tmp/ccoIKDmM.s", {st_mode=S_IFREG|0600, st_size=333416, ...}) = 0
unlink("/tmp/ccoIKDmM.s") = 0
exit_group(0) = ?
+++ exited with 0 +++
gcc的已应用补丁:(用于*-test-linux-gnu
中的支持musl)
diff -- a/gcc/config.gcc b/gcc/config.gcc
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -779,7 +779,7 @@ case ${target} in
*-*-*uclibc*)
tm_defines="$tm_defines DEFAULT_LIBC=LIBC_UCLIBC"
;;
- *-*-*musl*)
+ *-*-*musl* | *-test-*-gnu )
tm_defines="$tm_defines DEFAULT_LIBC=LIBC_MUSL"
;;
*)
diff -- a/libstdc++-v3/configure b/libstdc++-v3/configure
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -28912,7 +28912,7 @@ else
# First, test for "known" system libraries. We may be using newlib even
# on a hosted environment.
if test "x${with_newlib}" = "xyes"; then
- os_include_dir="os/newlib"
+ os_include_dir="os/generic"
$as_echo "#define HAVE_HYPOT 1" >>confdefs.h
diff -- a/libstdc++-v3/configure.host b/libstdc++-v3/configure.host
--- a/libstdc++-v3/configure.host
+++ b/libstdc++-v3/configure.host
@@ -393,3 +393,11 @@ case "${host}" in
abi_baseline_subdir_switch=--print-multi-os-directory
;;
esac
+
+# TEST Linux patch
+case "${host}" in
+ *-test-* | *-test-dev-* )
+ os_include_dir="os/generic"
+ ;;
+esac
+
./配置选项(gcc-###):
Using built-in specs.
COLLECT_GCC=gcc
Target: i686-test-linux
Configured with: /l/src/build/i686-test-linux/gcc-8.3.0/configure CFLAGS='-static -O2' CXXFLAGS='-static -O2'
--build=i686-test-linux --host=i686-test-linux --target=i686-test-linux --prefix=/usr/ --with-sysroot=/usr/
--with-native-system-header-dir=/include --with-local-prefix=/usr/ --with-newlib --without-headers --enable-languages=c,c++
--disable-libstdcxx --disable-nls --disable-shared --disable-multilib --disable-decimal-float --disable-threads
--disable-libada --disable-libatomic --disable-libffi --disable-libgomp --disable-libhsail-rt --disable-libitm
--disable-libmpx --disable-libobjc --disable-liboffloadmic --disable-libquadmath --disable-libsanitizer --disable-libssp
--disable-libstdc++-v3 --disable-libvtv --disable-bootstrap
Thread model: single
gcc version 8.3.0 (TEST Embedded Linux Toolchain for [i686])```
我已经测试了这些更改,但没有解决:
我的linux环境只有:
注意:我的linux没有任何软件包管理器。因此不能像“ sudo apt-get install g ++”那样使用它
答案 0 :(得分:0)
我用简单的解决方案解决了这个问题。
export PATH
此命令后,将使用相对路径进行编译。
找到这个的路:
$ PATH=${PATH}:/usr/libexec/gcc/i686-test-linux/8.3.0/
->成功
根据strace日志,我认为gcc不使用$ PATH搜索cc1 / cc1plus。为什么?
$ PATH=${PATH}:/usr/bin
->成功
$ echo ${PATH}
/sbin:/usr/sbin:/bin:/usr/bin
$ PATH=${PATH} gcc
->成功
$ gcc
和$ PATH=$PATH gcc
之间有什么区别?$ set
HOME='/'
HOSTNAME='TEST0'
IFS='
'
LINENO=''
OLDPWD='/'
OPTIND='1'
PATH='/sbin:/usr/sbin:/bin:/usr/bin'
PPID='2701'
PS1='\w \$ '
PS2='> '
PS4='+ '
PWD='/'
SHLVL='8'
TERM='linux'
$ export
export HOME='/'
export OLDPWD='/'
export PWD='/'
export SHLVL='8'
export TERM='linux'
哦,不将PATH作为环境变量导出。仅作为 shell 变量存在...