fw876 / helloworld

GNU General Public License v3.0
3.7k stars 2.66k forks source link

gn编译还是报错 #1399

Open love-dy opened 9 months ago

love-dy commented 9 months ago

加入 apt install clang 命令 github编译依然报错,请问大佬怎么解决呀

zxlhhyccc commented 9 months ago

love

请提供报错信息!我们在官方master分支下和immortalwrt编译正常。。。。

sunaihui commented 9 months ago

love

请提供报错信息!我们在官方master分支下和immortalwrt编译正常。。。。

MAKEFLAGS="" /home/sss/lede/staging_dir/host/bin/ninja  -j1 -C /home/sss/lede/build_dir/hostpkg/gn-2024-01-24-a2e2717e/out
ninja: Entering directory `/home/sss/lede/build_dir/hostpkg/gn-2024-01-24-a2e2717e/out'
[1/287] CXX src/base/command_line.o
FAILED: src/base/command_line.o 
clang++ -MMD -MF src/base/command_line.o.d -I../src -I. -DNDEBUG -O3 -fdata-sections -ffunction-sections -Werror -D_FILE_OFFSET_BITS=64 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -pthread -pipe -fno-exceptions -fno-rtti -fdiagnostics-color -Wall -Wextra -Wno-unused-parameter -Wextra-semi -Wundef -std=c++20 -Wrange-loop-analysis -Wextra-semi-stmt -c ../src/base/command_line.cc -o src/base/command_line.o
error: unknown warning option '-Wextra-semi-stmt'; did you mean '-Wextra-semi'? [-Werror,-Wunknown-warning-option]
error: invalid value 'c++20' in '-std=c++20'
note: use 'c++98' or 'c++03' for 'ISO C++ 1998 with amendments' standard
note: use 'gnu++98' or 'gnu++03' for 'ISO C++ 1998 with amendments and GNU extensions' standard
note: use 'c++11' for 'ISO C++ 2011 with amendments' standard
note: use 'gnu++11' for 'ISO C++ 2011 with amendments and GNU extensions' standard
note: use 'c++14' for 'ISO C++ 2014 with amendments' standard
note: use 'gnu++14' for 'ISO C++ 2014 with amendments and GNU extensions' standard
note: use 'c++17' for 'ISO C++ 2017 with amendments' standard
note: use 'gnu++17' for 'ISO C++ 2017 with amendments and GNU extensions' standard
note: use 'c++2a' for 'Working draft for ISO C++ 2020' standard
note: use 'gnu++2a' for 'Working draft for ISO C++ 2020 with GNU extensions' standard
ninja: build stopped: subcommand failed.
make[3]: *** [Makefile:58: /home/sss/lede/build_dir/hostpkg/gn-2024-01-24-a2e2717e/.built] Error 1
make[3]: Leaving directory '/home/sss/lede/feeds/helloworld/gn'
time: package/feeds/helloworld/gn/host-compile#0.13#0.11#0.40
    ERROR: package/feeds/helloworld/gn [host] failed to build.
make[2]: *** [package/Makefile:114: package/feeds/helloworld/gn/host/compile] Error 1
make[2]: Leaving directory '/home/sss/lede'
make[1]: *** [package/Makefile:110: /home/sss/lede/staging_dir/target-mipsel_24kc_musl/stamp/.package_compile] Error 2
make[1]: Leaving directory '/home/sss/lede'
make: *** [/home/sss/lede/include/toplevel.mk:231: world] Error 2
zxlhhyccc commented 9 months ago

看起来是编译环境的gcc版本问题,请再贴一下编译环境的gcc版本。。。因为编译环境的gcc版本必须是最低9.x版本

281677160 commented 9 months ago

看起来是编译环境的gcc版本问题,请再贴一下编译环境的gcc版本。。。因为编译环境的gcc版本必须是最低9.x版本

9.x版本的我这里编译不了,百度一下修改gcc版本搞定,云编译,本地编译都可用

sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo add-apt-repository ppa:ubuntu-toolchain-r/ppa
sudo apt-get install -y gcc-13
sudo apt-get install -y g++-13
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 60 --slave /usr/bin/g++ g++ /usr/bin/g++-13
zxlhhyccc commented 9 months ago

看起来是编译环境的gcc版本问题,请再贴一下编译环境的gcc版本。。。因为编译环境的gcc版本必须是最低9.x版本

9.x版本的我这里编译不了,百度一下修改gcc版本搞定,云编译,本地编译都可用

sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo add-apt-repository ppa:ubuntu-toolchain-r/ppa
sudo apt-get install -y gcc-13
sudo apt-get install -y g++-13
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 60 --slave /usr/bin/g++ g++ /usr/bin/g++-13

所以必须确保编译环境的gcc版本是9.x及以上。。。。

love-dy commented 9 months ago

image 升级GCC 13 还是云编译还是报错

love-dy commented 9 months ago

clang++: not found

sudo apt-get install clang

binge8 commented 9 months ago

看起来是编译环境的gcc版本问题,请再贴一下编译环境的gcc版本。。。因为编译环境的gcc版本必须是最低9.x版本

9.x版本的我这里编译不了,百度一下修改gcc版本搞定,云编译,本地编译都可用

sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo add-apt-repository ppa:ubuntu-toolchain-r/ppa
sudo apt-get install -y gcc-13
sudo apt-get install -y g++-13
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 60 --slave /usr/bin/g++ g++ /usr/bin/g++-13
Get:1 file:/etc/apt/apt-mirrors.txt Mirrorlist [142 B]
Hit:2 http://azure.archive.ubuntu.com/ubuntu jammy InRelease
Hit:6 https://packages.microsoft.com/ubuntu/22.04/prod jammy InRelease
Hit:3 http://azure.archive.ubuntu.com/ubuntu jammy-updates InRelease
Hit:4 http://azure.archive.ubuntu.com/ubuntu jammy-backports InRelease
Hit:5 http://azure.archive.ubuntu.com/ubuntu jammy-security InRelease
Hit:7 https://ppa.launchpadcontent.net/ubuntu-toolchain-r/test/ubuntu jammy InRelease
Reading package lists...
PPA publishes dbgsym, you may need to include 'main/debug' component
Repository: 'deb https://ppa.launchpadcontent.net/ubuntu-toolchain-r/test/ubuntu/ jammy main'
Description:
Toolchain test builds; see https://wiki.ubuntu.com/ToolChain

More info: https://launchpad.net/~ubuntu-toolchain-r/+archive/ubuntu/test
Adding repository.
Found existing deb entry in /etc/apt/sources.list.d/ubuntu-toolchain-r-ubuntu-test-jammy.list
Adding deb entry to /etc/apt/sources.list.d/ubuntu-toolchain-r-ubuntu-test-jammy.list
Found existing deb-src entry in /etc/apt/sources.list.d/ubuntu-toolchain-r-ubuntu-test-jammy.list
Adding disabled deb-src entry to /etc/apt/sources.list.d/ubuntu-toolchain-r-ubuntu-test-jammy.list
Adding key to /etc/apt/trusted.gpg.d/ubuntu-toolchain-r-ubuntu-test.gpg with fingerprint 60C317803A41BA51845E371A1E9377A2BA9EF27F
Get:1 file:/etc/apt/apt-mirrors.txt Mirrorlist [142 B]
Hit:2 http://azure.archive.ubuntu.com/ubuntu jammy InRelease
Hit:3 http://azure.archive.ubuntu.com/ubuntu jammy-updates InRelease
Hit:4 http://azure.archive.ubuntu.com/ubuntu jammy-backports InRelease
Hit:5 http://azure.archive.ubuntu.com/ubuntu jammy-security InRelease
Hit:6 https://packages.microsoft.com/ubuntu/22.04/prod jammy InRelease
Get:7 https://ppa.launchpadcontent.net/ubuntu-toolchain-r/ppa/ubuntu jammy InRelease [23.8 kB]
Hit:8 https://ppa.launchpadcontent.net/ubuntu-toolchain-r/test/ubuntu jammy InRelease
Get:9 https://ppa.launchpadcontent.net/ubuntu-toolchain-r/ppa/ubuntu jammy/main amd64 Packages [267 kB]
Get:10 https://ppa.launchpadcontent.net/ubuntu-toolchain-r/ppa/ubuntu jammy/main Translation-en [27.5 kB]
Fetched 319 kB in 1s (331 kB/s)
Reading package lists...
PPA publishes dbgsym, you may need to include 'main/debug' component
Repository: 'deb https://ppa.launchpadcontent.net/ubuntu-toolchain-r/ppa/ubuntu/ jammy main'
Description:
Toolchain builds for all architectures; see https://wiki.ubuntu.com/ToolChain

More info: https://launchpad.net/~ubuntu-toolchain-r/+archive/ubuntu/ppa
Adding repository.
Adding deb entry to /etc/apt/sources.list.d/ubuntu-toolchain-r-ubuntu-ppa-jammy.list
Adding disabled deb-src entry to /etc/apt/sources.list.d/ubuntu-toolchain-r-ubuntu-ppa-jammy.list
Adding key to /etc/apt/trusted.gpg.d/ubuntu-toolchain-r-ubuntu-ppa.gpg with fingerprint 60C317803A41BA51845E371A1E9377A2BA9EF27F
Reading package lists...
Building dependency tree...
Reading state information...
gcc-13 is already the newest version (13.1.0-8ubuntu1~22.04).
gcc-13 set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 8 not upgraded.
Reading package lists...
Building dependency tree...
Reading state information...
g++-13 is already the newest version (13.1.0-8ubuntu1~22.04).
0 upgraded, 0 newly installed, 0 to remove and 8 not upgraded.
update-alternatives: using /usr/bin/gcc-13 to provide /usr/bin/gcc (gcc) in auto mode
Reading package lists...
Building dependency tree...
Reading state information...
0 upgraded, 0 newly installed, 0 to remove and 8 not upgraded.

这个是没有安装成功吗

dfbucy090 commented 9 months ago

我也是卡在gn这里,希望哪位大侠出个详细解决方案,小白们叩谢。

love-dy commented 9 months ago

sudo apt-get install clang sudo add-apt-repository ppa:ubuntu-toolchain-r/test sudo add-apt-repository ppa:ubuntu-toolchain-r/ppa sudo apt-get install -y gcc-13 sudo apt-get install -y g++-13 sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 60 --slave /usr/bin/g++ g++ /usr/bin/g++-13

image 增加了以上几个命令还是不行,不知怎么搞了

zxlhhyccc commented 9 months ago

增加了以上几个命令还是不行,不知怎么搞了

我使用的gcc是9.4.0版本,你降级到这个版本绝对没有问题: image 或者如果gcc版本是13.0,添加这个补丁: gn/patches/010-gcc.patch

--- a/build/gen.py
+++ b/build/gen.py
@@ -368,7 +368,7 @@ def WriteGNNinja(path, platform, host, o
     cxx = os.environ.get('CXX', 'g++')
     ld = os.environ.get('LD', 'g++')
     ar = os.environ.get('AR', 'ar -X64')
-  elif platform.is_msys() or platform.is_mingw():
+  elif platform.is_msys() or platform.is_mingw() or platform.is_linux():
     cxx = os.environ.get('CXX', 'g++')
     ld = os.environ.get('LD', 'g++')
     ar = os.environ.get('AR', 'ar')
281677160 commented 9 months ago

sudo apt-get install clang sudo add-apt-repository ppa:ubuntu-toolchain-r/test sudo add-apt-repository ppa:ubuntu-toolchain-r/ppa sudo apt-get install -y gcc-13 sudo apt-get install -y g++-13 sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 60 --slave /usr/bin/g++ g++ /usr/bin/g++-13

image 增加了以上几个命令还是不行,不知怎么搞了

sudo apt-get install clang sudo add-apt-repository ppa:ubuntu-toolchain-r/test sudo add-apt-repository ppa:ubuntu-toolchain-r/ppa sudo apt-get install -y gcc-13 sudo apt-get install -y g++-13 sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 60 --slave /usr/bin/g++ g++ /usr/bin/g++-13

image 增加了以上几个命令还是不行,不知怎么搞了 QQ截图20240220003605 我的没问题,如果不执行更换gcc13的话,就编译不过去的,更换后就每次都成功

smdx commented 9 months ago

sudo apt-get install clang sudo add-apt-repository ppa:ubuntu-toolchain-r/test sudo add-apt-repository ppa:ubuntu-toolchain-r/ppa sudo apt-get install -y gcc-13 sudo apt-get install -y g++-13 sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 60 --slave /usr/bin/g++ g++ /usr/bin/g++-13 image 增加了以上几个命令还是不行,不知怎么搞了

sudo apt-get install clang sudo add-apt-repository ppa:ubuntu-toolchain-r/test sudo add-apt-repository ppa:ubuntu-toolchain-r/ppa sudo apt-get install -y gcc-13 sudo apt-get install -y g++-13 sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 60 --slave /usr/bin/g++ g++ /usr/bin/g++-13 image 增加了以上几个命令还是不行,不知怎么搞了 QQ截图20240220003605 我的没问题,如果不执行更换gcc13的话,就编译不过去的,更换后就每次都成功

大佬,在github云编译怎么更换gcc13啊?谢谢

NeedforGit commented 8 months ago

看起来是编译环境的gcc版本问题,请再贴一下编译环境的gcc版本。。。因为编译环境的gcc版本必须是最低9.x版本

9.x版本的我这里编译不了,百度一下修改gcc版本搞定,云编译,本地编译都可用

sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo add-apt-repository ppa:ubuntu-toolchain-r/ppa
sudo apt-get install -y gcc-13
sudo apt-get install -y g++-13
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 60 --slave /usr/bin/g++ g++ /usr/bin/g++-13

请问云编译的话,这些命令添加在哪里?

yuos-bit commented 7 months ago

看起来是编译环境的gcc版本问题,请再贴一下编译环境的gcc版本。。。因为编译环境的gcc版本必须是最低9.x版本

9.x版本的我这里编译不了,百度一下修改gcc版本搞定,云编译,本地编译都可用

sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo add-apt-repository ppa:ubuntu-toolchain-r/ppa
sudo apt-get install -y gcc-13
sudo apt-get install -y g++-13
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 60 --slave /usr/bin/g++ g++ /usr/bin/g++-13

请问云编译的话,这些命令添加在哪里?

- name: 初始化环境
  env:
    DEBIAN_FRONTEND: noninteractive
  run: |
    sudo rm -rf /etc/apt/sources.list.d/* /usr/share/dotnet /usr/local/lib/android /opt/ghc
    sudo -E apt-get -qq update
    sudo -E apt-get -qq install ack antlr3 asciidoc autoconf automake autopoint binutils bison build-essential \
    bzip2 ccache cmake cpio curl device-tree-compiler fastjar flex gawk gettext gcc-multilib g++-multilib \
    git gperf haveged help2man intltool libc6-dev-i386 libelf-dev libglib2.0-dev libgmp3-dev libltdl-dev \
    libmpc-dev libmpfr-dev libip4tc2 libncurses5-dev libncursesw5-dev libreadline-dev libssl-dev libtool lrzsz \
    mkisofs msmtp nano ninja-build p7zip p7zip-full patch pkgconf python2.7 python3 python3-pyelftools \
    libpython3-dev qemu-utils rsync scons squashfs-tools subversion swig texinfo uglifyjs upx-ucl unzip \
    vim wget xmlto xxd zlib1g-dev python3-setuptools clang
    sudo add-apt-repository ppa:ubuntu-toolchain-r/test
    sudo add-apt-repository ppa:ubuntu-toolchain-r/ppa
    sudo apt-get install -y gcc-13
    sudo apt-get install -y g++-13
    sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 60 --slave /usr/bin/g++ g++ /usr/bin/g++-13
    sudo timedatectl set-timezone "$TZ"
    sudo mkdir -p /workdir
    sudo chown $USER:$GROUPS /workdir