ligurio / unreliablefs

A FUSE-based fault injection filesystem.
https://ligurio.github.io/unreliablefs/unreliablefs.1.html
MIT License
174 stars 9 forks source link

Project does not compile without CFLAGS+=-fcommon #77

Closed 0mp closed 3 years ago

0mp commented 3 years ago

I am adding unreliablefs to the FreeBSD ports and I noticed that it does not compile unless I pass -fcommon to the compiler.

The offending variable seems to be conf:

FAILED: unreliablefs
: && /usr/bin/cc -O2 -pipe  -fstack-protector-strong -fno-strict-aliasing -O2 -pipe  -fstack-protector-strong -fno-strict-aliasing -fstack-protector-strong CMakeFiles/unreliablefs.dir/conf.c.o CMakeFiles/unreliablefs.dir/unreliablefs.c.o CMakeFiles/unreliablefs.dir/unreliablefs_errinj.c.o CMakeFiles/unreliablefs.dir/unreliablefs_ops.c.o -o unreliablefs  -Wl,-rpath,/usr/local/lib  /usr/local/lib/libfuse.so && :
ld: error: duplicate symbol: conf
>>> defined at unreliablefs.c
>>>            CMakeFiles/unreliablefs.dir/unreliablefs.c.o:(conf)
>>> defined at unreliablefs_errinj.c
>>>            CMakeFiles/unreliablefs.dir/unreliablefs_errinj.c.o:(.bss+0x0)
cc: error: linker command failed with exit code 1 (use -v to see invocation)
ligurio commented 3 years ago

Thanks for the report! It looks strange, because I check the compilation on FreeBSD 12, and everything fine there. Could you check a patch? https://patch-diff.githubusercontent.com/raw/ligurio/unreliablefs/pull/82.patch

0mp commented 3 years ago

The patch does help. I've tested it on FreeBSD 13.0.

NB: The thing with -fcommon is that the defaults changed in some recent Clang version and as a result a lot of software requires the -fcommon flag now (or a patch) to compile.

ligurio commented 3 years ago

Please share clang version and used cflags.

0mp commented 3 years ago

Here's a fragment of the build log of the unreliablefs port. The FreeBSD is 13.0-RELEASE:

===>  Building for fusefs-unreliablefs-0.1.0_1
[ 14% 5/7] /usr/bin/cc -DHAVE_UTIMENSAT -D_FILE_OFFSET_BITS=64 -I/usr/local/include/fuse -O2 -pipe  -fstack-protector-strong -fno-strict-aliasing -std=c11 -O2 -pipe  -fstack-protector-strong -fno-strict-aliasing -std=c11 -D_FILE_OFFSET_BITS=64 -Wall -Wextra -Wno-unused-parameter -MD -MT CMakeFiles/unreliablefs.dir/unreliablefs.c.o -MF CMakeFiles/unreliablefs.dir/unreliablefs.c.o.d -o CMakeFiles/unreliablefs.dir/unreliablefs.c.o -c /wrkdirs/usr/ports/sysutils/fusefs-unreliablefs/work/unreliablefs-0.1.0/unreliablefs.c
[ 28% 5/7] /usr/bin/cc -DHAVE_UTIMENSAT -D_FILE_OFFSET_BITS=64 -I/usr/local/include/fuse -O2 -pipe  -fstack-protector-strong -fno-strict-aliasing -std=c11 -O2 -pipe  -fstack-protector-strong -fno-strict-aliasing -std=c11 -D_FILE_OFFSET_BITS=64 -Wall -Wextra -Wno-unused-parameter -MD -MT CMakeFiles/unreliablefs.dir/conf.c.o -MF CMakeFiles/unreliablefs.dir/conf.c.o.d -o CMakeFiles/unreliablefs.dir/conf.c.o -c /wrkdirs/usr/ports/sysutils/fusefs-unreliablefs/work/unreliablefs-0.1.0/conf.c
[ 42% 5/7] /usr/bin/cc -DHAVE_UTIMENSAT -D_FILE_OFFSET_BITS=64 -I/usr/local/include/fuse -O2 -pipe  -fstack-protector-strong -fno-strict-aliasing -std=c11 -O2 -pipe  -fstack-protector-strong -fno-strict-aliasing -std=c11 -D_FILE_OFFSET_BITS=64 -Wall -Wextra -Wno-unused-parameter -MD -MT CMakeFiles/unreliablefs.dir/unreliablefs_errinj.c.o -MF CMakeFiles/unreliablefs.dir/unreliablefs_errinj.c.o.d -o CMakeFiles/unreliablefs.dir/unreliablefs_errinj.c.o -c /wrkdirs/usr/ports/sysutils/fusefs-unreliablefs/work/unreliablefs-0.1.0/unreliablefs_errinj.c
[ 57% 5/7] /usr/bin/cc -DHAVE_UTIMENSAT -D_FILE_OFFSET_BITS=64 -I/usr/local/include/fuse -O2 -pipe  -fstack-protector-strong -fno-strict-aliasing -std=c11 -O2 -pipe  -fstack-protector-strong -fno-strict-aliasing -std=c11 -D_FILE_OFFSET_BITS=64 -Wall -Wextra -Wno-unused-parameter -MD -MT CMakeFiles/unreliablefs.dir/unreliablefs_ops.c.o -MF CMakeFiles/unreliablefs.dir/unreliablefs_ops.c.o.d -o CMakeFiles/unreliablefs.dir/unreliablefs_ops.c.o -c /wrkdirs/usr/ports/sysutils/fusefs-unreliablefs/work/unreliablefs-0.1.0/unreliablefs_ops.c
[ 71% 6/7] : && /usr/bin/cc -O2 -pipe  -fstack-protector-strong -fno-strict-aliasing -std=c11 -O2 -pipe  -fstack-protector-strong -fno-strict-aliasing -std=c11 -fstack-protector-strong CMakeFiles/unreliablefs.dir/conf.c.o CMakeFiles/unreliablefs.dir/unreliablefs.c.o CMakeFiles/unreliablefs.dir/unreliablefs_errinj.c.o CMakeFiles/unreliablefs.dir/unreliablefs_ops.c.o -o unreliablefs  -Wl,-rpath,/usr/local/lib  /usr/local/lib/libfuse.so && :
[ 85% 6/7] /usr/bin/cc -D_FILE_OFFSET_BITS=64  -O2 -pipe  -fstack-protector-strong -fno-strict-aliasing -std=c11 -O2 -pipe  -fstack-protector-strong -fno-strict-aliasing -std=c11 -MD -MT tests/CMakeFiles/fsx.dir/fsx.c.o -MF tests/CMakeFiles/fsx.dir/fsx.c.o.d -o tests/CMakeFiles/fsx.dir/fsx.c.o -c /wrkdirs/usr/ports/sysutils/fusefs-unreliablefs/work/unreliablefs-0.1.0/tests/fsx.c
[100% 7/7] : && /usr/bin/cc -O2 -pipe  -fstack-protector-strong -fno-strict-aliasing -std=c11 -O2 -pipe  -fstack-protector-strong -fno-strict-aliasing -std=c11 -fstack-protector-strong tests/CMakeFiles/fsx.dir/fsx.c.o -o tests/fsx   && :

cc --version:

root@130a-default:~ # cc --version
FreeBSD clang version 11.0.1 (git@github.com:llvm/llvm-project.git llvmorg-11.0.1-0-g43ff75f2c3fe)
Target: x86_64-unknown-freebsd13.0
Thread model: posix
InstalledDir: /usr/bin

uname -a