Bug 251150 - Cannot compile zfsboot: no previous prototype for function 'main' [-Werror,-Wmissing-prototypes]
Summary: Cannot compile zfsboot: no previous prototype for function 'main' [-Werror,-W...
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: amd64 Any
: --- Affects Only Me
Assignee: Toomas Soome
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-11-15 09:34 UTC by markiyan.kushnir
Modified: 2020-11-15 14:05 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description markiyan.kushnir 2020-11-15 09:34:13 UTC
cc  -O2 -pipe -fno-common   -I/work/src.svn/stand/i386/btx/lib -nostdinc    -I/work/obj/work/src.svn/amd64.amd64/stand/libsa32 -I/work/src.svn/stand/libsa -D_STANDALONE -I/work/src.svn/sys -Ddouble=jagged-little-pill -Dfloat=floaty-mcfloatface -ffunction-sections -fdata-sections -DLOADER_GELI_SUPPORT -I/work/src.svn/stand/libsa/geli -DLOADER_DISK_SUPPORT -m32 -ffreestanding -mno-mmx -mno-sse -mno-avx -mno-avx2 -msoft-float -march=i386 -mno-relax -I. -Iinclude -DBOOTPROG=\"zfsboot\"  -O1  -DBOOT2  -DLOADER_GPT_SUPPORT  -DLOADER_MBR_SUPPORT  -DLOADER_ZFS_SUPPORT  -DLOADER_UFS_SUPPORT  -DSIOPRT=0x3f8  -DSIOFMT=0x3  -DSIOSPD=9600  -I/work/src.svn/stand/common  -I/work/src.svn/stand/i386/common  -I/work/src.svn/stand/i386/libi386  -I/work/src.svn/stand/libsa/zfs  -I/work/src.svn/sys/crypto/skein  -I/work/src.svn/sys/cddl/boot/zfs  -I/work/src.svn/sys/contrib/openzfs/include  -I/work/src.svn/sys/contrib/openzfs/include/os/freebsd/spl  -I/work/src.svn/sys/contrib/openzfs/include/os/freebsd/zfs  -I/work/src.svn/sys/cddl/contrib/opensolaris/common/lz4  -I/work/src.svn/stand/i386/boot2  -Wall -Waggregate-return -Wbad-function-cast -Wno-cast-align  -Wmissing-declarations -Wmissing-prototypes -Wnested-externs  -Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings -g -MD  -MF.depend.zfsboot.o -MTzfsboot.o -std=gnu99 -Wno-format-zero-length -nobuiltininc -idirafter /usr/lib/clang/9.0.1/include -Wsystem-headers -Werror -Wno-pointer-sign -Wno-empty-body -Wno-string-plus-int -Wno-unused-const-variable -Wno-tautological-compare -Wno-unused-value -Wno-parentheses-equality -Wno-unused-function -Wno-enum-conversion -Wno-unused-local-typedef -Wno-address-of-packed-member -Wno-switch -Wno-switch-enum -Wno-knr-promoted-parameter -Wno-parentheses  -Oz -Qunused-arguments    -c /work/src.svn/stand/i386/zfsboot/zfsboot.c -o zfsboot.o
/work/src.svn/stand/i386/zfsboot/zfsboot.c:165:1: error: no previous prototype for function 'main' [-Werror,-Wmissing-prototypes]
main(void)
^
/work/src.svn/stand/i386/zfsboot/zfsboot.c:164:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
int
^
static
1 error generated.
*** Error code 1

Stop.
make: stopped in /work/src.svn/stand/i386/zfsboot


I'd suggest to add the main() declaration much like it's in gptboot.
Comment 1 markiyan.kushnir 2020-11-15 09:45:34 UTC
Revision: 367699
Comment 2 markiyan.kushnir 2020-11-15 09:47:42 UTC
# cat /etc/src.conf 
WITHOUT_ATM=ok
WITH_BSD_GREP=ok
WITHOUT_CROSS_COMPILER=ok
WITH_CTF=ok
WITHOUT_DMAGENT=ok
WITH_EXTRA_TCP_STACKS=ok
WITHOUT_FLOPPY=ok
WITHOUT_GNU_DIFF=ok
WITHOUT_GNU_GREP=ok
WITHOUT_LIB32=ok
WITHOUT_LLVM_TARGET_ALL=ok
WITH_LOADER_LUA=ok
WITHOUT_MAIL=ok
WITHOUT_REPRODUCIBLE_BUILD=ok

# cat /etc/make.conf 
MALLOC_PRODUCTION=true
Comment 3 Toomas Soome freebsd_committer 2020-11-15 11:41:47 UTC
what compiler do you have? because I do not get this error:

root@freebsd-2:/usr/src/stand/i386/zfsboot # make
cc  -O2 -pipe -fno-common   -I/usr/src/stand/i386/btx/lib -nostdinc    -I/usr/obj/usr/src/amd64.amd64/stand/libsa32 -I/usr/src/stand/libsa -D_STANDALONE -I/usr/src/sys -Ddouble=jagged-little-pill -Dfloat=floaty-mcfloatface -ffunction-sections -fdata-sections -DLOADER_GELI_SUPPORT -I/usr/src/stand/libsa/geli -DLOADER_DISK_SUPPORT -m32 -ffreestanding -mno-mmx -mno-sse -mno-avx -mno-avx2 -msoft-float -march=i386 -mno-relax -I. -Iinclude -DBOOTPROG=\"zfsboot\"  -O1  -DBOOT2  -DLOADER_GPT_SUPPORT  -DLOADER_MBR_SUPPORT  -DLOADER_ZFS_SUPPORT  -DLOADER_UFS_SUPPORT  -DSIOPRT=0x3f8  -DSIOFMT=0x3  -DSIOSPD=9600  -I/usr/src/stand/common  -I/usr/src/stand/i386/common  -I/usr/src/stand/i386/libi386  -I/usr/src/stand/libsa/zfs  -I/usr/src/sys/crypto/skein  -I/usr/src/sys/cddl/boot/zfs  -I/usr/src/sys/contrib/openzfs/include  -I/usr/src/sys/contrib/openzfs/include/os/freebsd/spl  -I/usr/src/sys/contrib/openzfs/include/os/freebsd/zfs  -I/usr/src/sys/cddl/contrib/opensolaris/common/lz4  -I/usr/src/stand/i386/boot2  -Wall -Waggregate-return -Wbad-function-cast -Wno-cast-align  -Wmissing-declarations -Wmissing-prototypes -Wnested-externs  -Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings -g -MD  -MF.depend.zfsboot.o -MTzfsboot.o -std=gnu99 -Wno-format-zero-length -Wsystem-headers -Werror -Wno-pointer-sign -Wno-empty-body -Wno-string-plus-int -Wno-unused-const-variable -Wno-tautological-compare -Wno-unused-value -Wno-parentheses-equality -Wno-unused-function -Wno-enum-conversion -Wno-unused-local-typedef -Wno-address-of-packed-member -Wno-switch -Wno-switch-enum -Wno-knr-promoted-parameter -Wno-parentheses  -Oz -Qunused-arguments    -c /usr/src/stand/i386/zfsboot/zfsboot.c -o zfsboot.o
ld -m elf_i386_fbsd -static -N --gc-sections --defsym ORG=0x2000 -T /usr/src/stand/i386/boot.ldscript -o zfsboot.out /usr/obj/usr/src/amd64.amd64/stand/i386/btx/lib/crt0.o zfsboot.o sio.o cons.o bcache.o devopen.o disk.o part.o zfs_cmd.o /usr/obj/usr/src/amd64.amd64/stand/i386/libi386/libi386.a /usr/obj/usr/src/amd64.amd64/stand/libsa32/libsa32.a
objcopy -S -O binary zfsboot.out zfsboot.bin
btxld -v -E 0x2000 -f bin -b /usr/obj/usr/src/amd64.amd64/stand/i386/btx/btx/btx -l zfsboot.ldr  -o zfsboot.ld -P 1 zfsboot.bin
kernel: ver=1.02 size=6b0 load=9000 entry=9010 map=16M pgctl=1:1
client: fmt=bin size=27f84 text=0 data=0 bss=0 entry=0
output: fmt=bin size=28634 text=0 data=28634 org=0 entry=0
96716 bytes available
dd status=none if=zfsboot.ld of=zfsboot2 bs=262144 conv=sync
cat zfsboot1 zfsboot2 > zfsboot
root@freebsd-2:/usr/src/stand/i386/zfsboot # cc -v
FreeBSD clang version 11.0.0 (git@github.com:llvm/llvm-project.git llvmorg-11.0.0-rc5-0-g60a25202a7d)
Target: x86_64-unknown-freebsd13.0
Thread model: posix
InstalledDir: /usr/bin
root@freebsd-2:/usr/src/stand/i386/zfsboot #

Of course we can add this prototype, but I'd like to understand why you have this error and I do not.
Comment 4 markiyan.kushnir 2020-11-15 12:16:40 UTC
I compiled it with a clang dating before Mar 2020.
Comment 5 commit-hook freebsd_committer 2020-11-15 14:04:41 UTC
A commit references this bug:

Author: tsoome
Date: Sun Nov 15 14:04:27 UTC 2020
New revision: 367710
URL: https://svnweb.freebsd.org/changeset/base/367710

Log:
  zfsboot: add prototype for main()

  Some compilers are complaining about missing prototype.

  PR:		251150
  Reported by:	markiyan.kushnir@gmail.com

Changes:
  head/stand/i386/zfsboot/zfsboot.c