Nuclei-Software / nuclei-linux-sdk

Nuclei RISC-V Linux Software Development Kit
Apache License 2.0
38 stars 9 forks source link

Build fail in ubuntu 22.04 c-stack.c:55:26: error: missing binary operator before token "(" #19

Open fanghuaqi opened 6 months ago

fanghuaqi commented 6 months ago

如下图所示

make[5]: Entering directory '/work/work/evalsoc/buildroot_initramfs/build/host-m4-1.4.18/lib'
  CC       binary-io.o
  CC       gl_avltree_oset.o
  CC       c-ctype.o
  CC       c-stack.o
  CC       c-strcasecmp.o
  CC       cloexec.o
  CC       c-strncasecmp.o
  CC       clean-temp.o
  CC       closeout.o
  CC       close-stream.o
  CC       closein.o
  CC       basename.o
  CC       dirname.o
  CC       dirname-lgpl.o
  CC       basename-lgpl.o
  CC       stripslash.o
  CC       execute.o
  CC       exitfail.o
In file included from /usr/include/signal.h:328,
                 from ./signal.h:52,
                 from c-stack.c:49:
c-stack.c:55:26: error: missing binary operator before token "("
   55 | #elif HAVE_LIBSIGSEGV && SIGSTKSZ < 16384
      |                          ^~~~~~~~
  CC       fd-safer-flag.o
  CC       fatal-signal.o
  CC       fd-hook.o
  CC       dup-safer-flag.o
make[5]: *** [Makefile:1915: c-stack.o] Error 1
make[5]: *** Waiting for unfinished jobs....
  CC       filenamecat.o

image

fanghuaqi commented 6 months ago

上面是ubuntu 的版本不对,需要使用 ubuntu 20.04才行, 如果需要使用 22.04,请切到 dev_nuclei_5.10_v2 分支测试,参见 https://github.com/Nuclei-Software/nuclei-linux-sdk/issues/19#issuecomment-1867533784

fanghuaqi commented 6 months ago

似乎是这个bug导致的 https://bugs.buildroot.org/show_bug.cgi?id=13721

修复的commit参见 https://git.buildroot.org/buildroot/commit/?id=5a9504831f3fa1ef3be334036c93da30150fde55

dev_nuclei_next的分支的buildroot版本刚好是2020.11.2 这个版本, 在这个修复之前,因此会有这个bug,建议切到 dev_nuclei_5.10_v2 这个分支测试。

关于分支介绍参见 #2

fanghuaqi commented 6 months ago

如果使用root账户构建(例如docker下的root)可能会报如下错误

checking whether mkdir handles trailing slash... yes
checking whether mkdir handles trailing dot... yes
checking for mkdtemp... yes
checking whether mkfifo rejects trailing slashes... yes
checking whether mknod can create fifo without root privileges... configure: error: in `/work/work/evalsoc/buildroot_initramfs/build/host-tar-1.29':
configure: error: you should not run configure as root (set FORCE_UNSAFE_CONFIGURE=1 in environment to bypass this check)
See `config.log' for more details
make[1]: *** [package/pkg-generic.mk:240: /work/work/evalsoc/buildroot_initramfs/build/host-tar-1.29/.stamp_configured] Error 1

解决方案 就是 运行 export FORCE_UNSAFE_CONFIGURE=1

但是不建议使用 root账户,强烈反对root和普通用户混用,会带来一堆问题。

fanghuaqi commented 6 months ago

测试ubuntu 22.04 的docker,下载代码,切换到 dev_nuclei_5.10_v2 分支,并获取最新代码,构建freeloader和bootimages,且运行qemu,没有问题

测试 commit为 https://github.com/Nuclei-Software/nuclei-linux-sdk/commit/ff7509ed7c710dca299ab2202077f0c4b11f2094

# in host
docker run -it ubuntu:22.04
# in docker now, default is root account
# not recommend to use root account in normal non-docker environment
# update apt package index
apt update
git clone -b dev_nuclei_5.10_v2 --depth 5 https://github.com/Nuclei-Software/nuclei-linux-sdk
cd nuclei-linux-sdk
git submodule update --init --depth=5
# please make sure source code cloned and updated successfully without any error 
# install required packages
xargs apt install -y < .github/apt.txt
# file is also required
apt install file
#  you should not run configure as root (set FORCE_UNSAFE_CONFIGURE=1 in environment to bypass this check)
export FORCE_UNSAFE_CONFIGURE=1
# build freeloader and bootimages
make freeloader bootimages
# install qemu via wget
wget https://nucleisys.com/upload/files/toochain/qemu/nuclei-qemu-2023.10-linux-x64.tar.gz
tar -xzf nuclei-qemu-2023.10-linux-x64.tar.gz
export PATH=$(pwd)/qemu/bin:$PATH
# check required libraries are installed or not for qemu
ldd `which qemu-system-riscv64`
# Fix gdb missing libgmp.so.3, see https://github.com/Nuclei-Software/nuclei-linux-sdk/issues/5
ln -s /lib/x86_64-linux-gnu/libgmp.so /lib/x86_64-linux-gnu/libgmp.so.3
# run in qemu
make run_qemu

image

image

image

fanghuaqi commented 6 months ago

You can try dev_nuclei_next and dev_nuclei_5.10 branch using Ubuntu 22.04 now, I think it is supported now, just try like https://github.com/Nuclei-Software/nuclei-linux-sdk/issues/19#issuecomment-1867533784