编译错误 target x86 软件包 gptfdisk
详细叙述
我认为是代码bug导致的编译错误。
重复 issue
- [X] 没有类似的 issue
具体型号
x86设备
详细日志
make[3]: Entering directory '/workdir/openwrt/feeds/packages/utils/gptfdisk'
rm -f /workdir/openwrt/build_dir/target-x86_64_musl/gptfdisk-1.0.8/.built
touch /workdir/openwrt/build_dir/target-x86_64_musl/gptfdisk-1.0.8/.built_check
CFLAGS="-Os -pipe -fno-caller-saves -fno-plt -fhonour-copts -fmacro-prefix-map=/workdir/openwrt/build_dir/target-x86_64_musl/gptfdisk-1.0.8=gptfdisk-1.0.8 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -I/workdir/openwrt/staging_dir/toolchain-x86_64_gcc-11.3.0_musl/usr/include -I/workdir/openwrt/staging_dir/toolchain-x86_64_gcc-11.3.0_musl/include/fortify -I/workdir/openwrt/staging_dir/toolchain-x86_64_gcc-11.3.0_musl/include " CXXFLAGS="-Os -pipe -fno-caller-saves -fno-plt -fhonour-copts -fmacro-prefix-map=/workdir/openwrt/build_dir/target-x86_64_musl/gptfdisk-1.0.8=gptfdisk-1.0.8 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -std=c++11 -ffunction-sections -fdata-sections -fno-rtti -flto -Wno-format-security -I/workdir/openwrt/staging_dir/toolchain-x86_64_gcc-11.3.0_musl/usr/include -I/workdir/openwrt/staging_dir/toolchain-x86_64_gcc-11.3.0_musl/include/fortify -I/workdir/openwrt/staging_dir/toolchain-x86_64_gcc-11.3.0_musl/include " LDFLAGS="-L/workdir/openwrt/staging_dir/toolchain-x86_64_gcc-11.3.0_musl/usr/lib -L/workdir/openwrt/staging_dir/toolchain-x86_64_gcc-11.3.0_musl/lib -znow -zrelro -Wl,--gc-sections,--as-needed " make -C /workdir/openwrt/build_dir/target-x86_64_musl/gptfdisk-1.0.8/. AR="x86_64-openwrt-linux-musl-gcc-ar" AS="x86_64-openwrt-linux-musl-gcc -c -Os -pipe -fno-caller-saves -fno-plt -fhonour-copts -fmacro-prefix-map=/workdir/openwrt/build_dir/target-x86_64_musl/gptfdisk-1.0.8=gptfdisk-1.0.8 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro" LD=x86_64-openwrt-linux-musl-ld NM="x86_64-openwrt-linux-musl-gcc-nm" CC="x86_64-openwrt-linux-musl-gcc" GCC="x86_64-openwrt-linux-musl-gcc" CXX="x86_64-openwrt-linux-musl-g++" RANLIB="x86_64-openwrt-linux-musl-gcc-ranlib" STRIP=x86_64-openwrt-linux-musl-strip OBJCOPY=x86_64-openwrt-linux-musl-objcopy OBJDUMP=x86_64-openwrt-linux-musl-objdump SIZE=x86_64-openwrt-linux-musl-size CROSS="x86_64-openwrt-linux-musl-" ARCH="x86_64" ;
make[4]: Entering directory '/workdir/openwrt/build_dir/target-x86_64_musl/gptfdisk-1.0.8'
x86_64-openwrt-linux-musl-g++ -Os -pipe -fno-caller-saves -fno-plt -fhonour-copts -fmacro-prefix-map=/workdir/openwrt/build_dir/target-x86_64_musl/gptfdisk-1.0.8=gptfdisk-1.0.8 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -std=c++11 -ffunction-sections -fdata-sections -fno-rtti -flto -Wno-format-security -I/workdir/openwrt/staging_dir/toolchain-x86_64_gcc-11.3.0_musl/usr/include -I/workdir/openwrt/staging_dir/toolchain-x86_64_gcc-11.3.0_musl/include/fortify -I/workdir/openwrt/staging_dir/toolchain-x86_64_gcc-11.3.0_musl/include -Wall -D_FILE_OFFSET_BITS=64 -c -o diskio-unix.o diskio-unix.cc
diskio-unix.cc: In member function 'int DiskIO::OpenForRead()':
diskio-unix.cc:55:18: error: aggregate 'DiskIO::OpenForRead()::stat64 st' has incomplete type and cannot be defined
55 | struct stat64 st;
| ^~
diskio-unix.cc:81:14: error: 'fstat64' was not declared in this scope; did you mean 'stat64'?
81 | if (fstat64(fd, &st) == 0) {
| ^~~~~~~
| stat64
diskio-unix.cc: In member function 'int DiskIO::Seek(uint64_t)':
diskio-unix.cc:314:4: error: 'off64_t' was not declared in this scope; did you mean 'off_t'?
314 | off64_t seekTo, sought;
| ^~~~~~~
| off_t
diskio-unix.cc:322:7: error: 'seekTo' was not declared in this scope; did you mean 'fseeko'?
322 | seekTo = sector * (uint64_t) GetBlockSize();
| ^~~~~~
| fseeko
diskio-unix.cc:323:7: error: 'sought' was not declared in this scope
323 | sought = lseek64(fd, seekTo, SEEK_SET);
| ^~~~~~
diskio-unix.cc:323:16: error: 'lseek64' was not declared in this scope; did you mean 'lseek'?
323 | sought = lseek64(fd, seekTo, SEEK_SET);
| ^~~~~~~
| lseek
diskio-unix.cc: In member function 'uint64_t DiskIO::DiskSize(int*)':
diskio-unix.cc:431:4: error: 'off64_t' was not declared in this scope; did you mean 'off_t'?
431 | off64_t bytes = 0; // size in bytes
| ^~~~~~~
| off_t
diskio-unix.cc:432:18: error: aggregate 'DiskIO::DiskSize(int*)::stat64 st' has incomplete type and cannot be defined
432 | struct stat64 st;
| ^~
diskio-unix.cc:491:14: error: 'fstat64' was not declared in this scope; did you mean 'stat64'?
491 | if (fstat64(fd, &st) == 0) {
| ^~~~~~~
| stat64
diskio-unix.cc:492:13: error: 'bytes' was not declared in this scope
492 | bytes = st.st_size;
| ^~~~~
make[4]: *** [
the same issue, need help
/build_dir/target-x86_64_musl/gptfdisk-1.0.8/diskio-unix.cc
using namespace std;
-#ifdef __APPLE__
+#if defined(__APPLE__) || defined(__linux__)
#define off64_t off_t
+#define stat64 stat
+#define fstat64 fstat
+#define lstat64 lstat
+#define lseek64 lseek
#endif