Repository: conan-io/conan-center-index

Issue:
[package] libbsd/0.10.0: does not compile on apple silicon
I am trying to compile without success libbsd/0.10.0 on apple silicon. See logs for more insight on the compilation error.

### Package and Environment Details (include every applicable attribute)
  * Package Name/Version: **libbsd/0.10.0**
  * Operating System+version: **Mac OS BigSur**
  * Compiler+version: **Apple Clang 12**
  * Docker image: **none**
  * Conan version: **conan 1.32.1**
  * Python version: **Python 3.8.2**


### Conan profile (output of `conan profile show default` or `conan profile show <profile>` if custom profile is in use)
```
Configuration for profile default:

[settings]
os=Macos
os_build=Macos
arch=armv8.3
arch_build=armv8.3
compiler=apple-clang
compiler.version=12.0
compiler.libcxx=libc++
build_type=Release
[options]
[build_requires]
[env]
```


### Steps to reproduce (Include if Applicable)

conan install libbsd/0.10.0@ --build missing

### Logs (Include/Attach if Applicable)
<details><summary>Click to expand log</summary>

```
...
Configuration:
[settings]
arch=armv8.3
arch_build=armv8.3
build_type=Release
compiler=apple-clang
compiler.libcxx=libc++
compiler.version=12.0
os=Macos
os_build=Macos
[options]
[build_requires]
[env]

libbsd/0.10.0: WARN: Package binary is corrupted, removing: 68e2a114b5f505b6553899369b5c9590a42898d7
Installing package: libbsd/0.10.0
Requirements
    libbsd/0.10.0 from 'conan-center' - Cache
Packages
    libbsd/0.10.0:68e2a114b5f505b6553899369b5c9590a42898d7 - Build
Build requirements
    autoconf/2.69 from 'conan-center' - Cache
    automake/1.16.2 from 'conan-center' - Cache
    libtool/2.4.6 from 'conan-center' - Cache
    m4/1.4.18 from 'conan-center' - Cache
Build requirements packages
    autoconf/2.69:cc471ed355602ffa7007968c83aa4e7e648a38b5 - Cache
    automake/1.16.2:3c28ba69276b46fd46e9c2060ba991d725ccab43 - Cache
    libtool/2.4.6:88cc1b806ca4308ad0d7e9213f9106b236b83a76 - Cache
    m4/1.4.18:2b5b4b5bfa456a6fc6648b635a72cfb45e757184 - Cache

Installing (downloading, building) binaries...
m4/1.4.18: Already installed!
m4/1.4.18: Appending PATH environment variable: /Users/syl/.conan/data/m4/1.4.18/_/_/package/2b5b4b5bfa456a6fc6648b635a72cfb45e757184/bin
m4/1.4.18: Setting M4 environment variable: /Users/syl/.conan/data/m4/1.4.18/_/_/package/2b5b4b5bfa456a6fc6648b635a72cfb45e757184/bin/m4
autoconf/2.69: Already installed!
autoconf/2.69: Appending PATH env var with : /Users/syl/.conan/data/autoconf/2.69/_/_/package/cc471ed355602ffa7007968c83aa4e7e648a38b5/bin
autoconf/2.69: Setting AC_MACRODIR to /Users/syl/.conan/data/autoconf/2.69/_/_/package/cc471ed355602ffa7007968c83aa4e7e648a38b5/bin/share/autoconf
autoconf/2.69: Setting AUTOCONF to /Users/syl/.conan/data/autoconf/2.69/_/_/package/cc471ed355602ffa7007968c83aa4e7e648a38b5/bin/autoconf
autoconf/2.69: Setting AUTORECONF to /Users/syl/.conan/data/autoconf/2.69/_/_/package/cc471ed355602ffa7007968c83aa4e7e648a38b5/bin/autoreconf
autoconf/2.69: Setting AUTOHEADER to /Users/syl/.conan/data/autoconf/2.69/_/_/package/cc471ed355602ffa7007968c83aa4e7e648a38b5/bin/autoheader
autoconf/2.69: Setting AUTOM4TE to /Users/syl/.conan/data/autoconf/2.69/_/_/package/cc471ed355602ffa7007968c83aa4e7e648a38b5/bin/autom4te
autoconf/2.69: Setting AUTOM4TE_PERLLIBDIR to /Users/syl/.conan/data/autoconf/2.69/_/_/package/cc471ed355602ffa7007968c83aa4e7e648a38b5/bin/share/autoconf
automake/1.16.2: Already installed!
automake/1.16.2: Appending PATH env var with : /Users/syl/.conan/data/automake/1.16.2/_/_/package/3c28ba69276b46fd46e9c2060ba991d725ccab43/bin
automake/1.16.2: Setting ACLOCAL to /Users/syl/.conan/data/automake/1.16.2/_/_/package/3c28ba69276b46fd46e9c2060ba991d725ccab43/bin/aclocal
automake/1.16.2: Setting AUTOMAKE_DATADIR to /Users/syl/.conan/data/automake/1.16.2/_/_/package/3c28ba69276b46fd46e9c2060ba991d725ccab43/bin/share
automake/1.16.2: Setting AUTOMAKE_LIBDIR to /Users/syl/.conan/data/automake/1.16.2/_/_/package/3c28ba69276b46fd46e9c2060ba991d725ccab43/bin/share/automake-1.16
automake/1.16.2: Setting AUTOMAKE_PERLLIBDIR to /Users/syl/.conan/data/automake/1.16.2/_/_/package/3c28ba69276b46fd46e9c2060ba991d725ccab43/bin/share/automake-1.16
automake/1.16.2: Setting AUTOMAKE to /Users/syl/.conan/data/automake/1.16.2/_/_/package/3c28ba69276b46fd46e9c2060ba991d725ccab43/bin/automake
automake/1.16.2: Append M4 include directories to AUTOMAKE_CONAN_INCLUDES environment variable
libtool/2.4.6: Already installed!
libtool/2.4.6: Appending PATH env: /Users/syl/.conan/data/libtool/2.4.6/_/_/package/88cc1b806ca4308ad0d7e9213f9106b236b83a76/bin
libtool/2.4.6: Setting LIBTOOLIZE env to /Users/syl/.conan/data/libtool/2.4.6/_/_/package/88cc1b806ca4308ad0d7e9213f9106b236b83a76/bin/libtoolize
libtool/2.4.6: Appending ACLOCAL_PATH env: /Users/syl/.conan/data/libtool/2.4.6/_/_/package/88cc1b806ca4308ad0d7e9213f9106b236b83a76/bin/share/aclocal
libtool/2.4.6: Setting LIBTOOL_PREFIX environment variable to /Users/syl/.conan/data/libtool/2.4.6/_/_/package/88cc1b806ca4308ad0d7e9213f9106b236b83a76
libtool/2.4.6: Setting LIBTOOL_DATADIR environment variable to /Users/syl/.conan/data/libtool/2.4.6/_/_/package/88cc1b806ca4308ad0d7e9213f9106b236b83a76/bin/share
libtool/2.4.6: Setting LIBTOOL_PKGAUXDIR environment variable to /Users/syl/.conan/data/libtool/2.4.6/_/_/package/88cc1b806ca4308ad0d7e9213f9106b236b83a76/bin/share/libtool/build-aux
libtool/2.4.6: Setting LIBTOOL_PKGLTDLDIR environment variable to /Users/syl/.conan/data/libtool/2.4.6/_/_/package/88cc1b806ca4308ad0d7e9213f9106b236b83a76/bin/share/libtool
libtool/2.4.6: Setting LIBTOOL_ACLOCALDIR environment variable to /Users/syl/.conan/data/libtool/2.4.6/_/_/package/88cc1b806ca4308ad0d7e9213f9106b236b83a76/bin/share/aclocal
libtool/2.4.6: Appending AUTOMAKE_CONAN_INCLUDES environment variable: /Users/syl/.conan/data/libtool/2.4.6/_/_/package/88cc1b806ca4308ad0d7e9213f9106b236b83a76/bin/share/aclocal
libbsd/0.10.0: Applying build-requirement: libtool/2.4.6
libbsd/0.10.0: Applying build-requirement: automake/1.16.2
libbsd/0.10.0: Applying build-requirement: autoconf/2.69
libbsd/0.10.0: Applying build-requirement: m4/1.4.18
libbsd/0.10.0: WARN: Build folder is dirty, removing it: /Users/syl/.conan/data/libbsd/0.10.0/_/_/build/68e2a114b5f505b6553899369b5c9590a42898d7
libbsd/0.10.0: Copying sources to build folder
libbsd/0.10.0: Building your package in /Users/syl/.conan/data/libbsd/0.10.0/_/_/build/68e2a114b5f505b6553899369b5c9590a42898d7
libbsd/0.10.0: Generator txt created conanbuildinfo.txt
libbsd/0.10.0: Calling build()
autoreconf: Entering directory `.'
autoreconf: configure.ac: not using Gettext
autoreconf: running: /Users/syl/.conan/data/automake/1.16.2/_/_/package/3c28ba69276b46fd46e9c2060ba991d725ccab43/bin/aclocal --force -I m4
autoreconf: configure.ac: tracing
autoreconf: running: /Users/syl/.conan/data/libtool/2.4.6/_/_/package/88cc1b806ca4308ad0d7e9213f9106b236b83a76/bin/libtoolize --copy --force
libtoolize: putting auxiliary files in AC_CONFIG_AUX_DIR, 'build-aux'.
libtoolize: copying file 'build-aux/ltmain.sh'
libtoolize: putting macros in AC_CONFIG_MACRO_DIRS, 'm4'.
libtoolize: copying file 'm4/libtool.m4'
libtoolize: copying file 'm4/ltoptions.m4'
libtoolize: copying file 'm4/ltsugar.m4'
libtoolize: copying file 'm4/ltversion.m4'
libtoolize: copying file 'm4/lt~obsolete.m4'
autoreconf: running: /Users/syl/.conan/data/autoconf/2.69/_/_/package/cc471ed355602ffa7007968c83aa4e7e648a38b5/bin/autoconf --force
autoreconf: running: /Users/syl/.conan/data/autoconf/2.69/_/_/package/cc471ed355602ffa7007968c83aa4e7e648a38b5/bin/autoheader --force
autoreconf: running: /Users/syl/.conan/data/automake/1.16.2/_/_/package/3c28ba69276b46fd46e9c2060ba991d725ccab43/bin/automake --add-missing --copy --force-missing
configure.ac:25: installing 'build-aux/compile'
configure.ac:9: installing 'build-aux/missing'
src/Makefile.am: installing 'build-aux/depcomp'
autoreconf: Leaving directory `.'
libbsd/0.10.0: Calling:
 > source_subfolder/configure '--disable-shared' '--enable-static' '--prefix=/Users/syl/.conan/data/libbsd/0.10.0/_/_/package/68e2a114b5f505b6553899369b5c9590a42898d7' '--bindir=${prefix}/bin' '--sbindir=${prefix}/bin' '--libexecdir=${prefix}/bin' '--libdir=${prefix}/lib' '--includedir=${prefix}/include' '--oldincludedir=${prefix}/include' '--datarootdir=${prefix}/share' --build=x86_64-apple-darwin --host=aarch64-apple-darwin
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for aarch64-apple-darwin-strip... no
checking for strip... strip
configure: WARNING: using cross tools not prefixed with host triplet
checking for a thread-safe mkdir -p... source_subfolder/build-aux/install-sh -c -d
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether make supports nested variables... (cached) yes
checking whether make supports the include directive... yes (GNU style)
checking for aarch64-apple-darwin-gcc... no
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... yes
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
checking dependency style of gcc... gcc3
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking minix/config.h usability... no
checking minix/config.h presence... no
checking for minix/config.h... no
checking whether it is safe to define __EXTENSIONS__... yes
checking for special C compiler options needed for large files... no
checking for _FILE_OFFSET_BITS value needed for large files... no
checking build system type... x86_64-apple-darwin
checking host system type... aarch64-apple-darwin
checking how to print strings... printf
checking for a sed that does not truncate output... /usr/bin/sed
checking for fgrep... /usr/bin/grep -F
checking for ld used by gcc... /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld
checking if the linker (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld) is GNU ld... no
checking for BSD- or MS-compatible name lister (nm)... no
checking for aarch64-apple-darwin-dumpbin... no
checking for aarch64-apple-darwin-link... no
checking for dumpbin... no
checking for link... link -dump
checking the name lister (nm) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 786432
checking how to convert x86_64-apple-darwin file names to aarch64-apple-darwin format... func_convert_file_noop
checking how to convert x86_64-apple-darwin file names to toolchain format... func_convert_file_noop
checking for /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld option to reload object files... -r
checking for aarch64-apple-darwin-objdump... no
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for aarch64-apple-darwin-dlltool... no
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for aarch64-apple-darwin-ar... no
checking for ar... ar
checking for archiver @FILE support... no
checking for aarch64-apple-darwin-strip... strip
checking for aarch64-apple-darwin-ranlib... no
checking for ranlib... ranlib
checking command to parse nm output from gcc object... ok
checking for sysroot... no
checking for a working dd... /bin/dd
checking how to truncate binary pipes... /bin/dd bs=4096 count=1
checking for aarch64-apple-darwin-mt... no
checking for mt... no
checking if : is a manifest tool... no
checking for aarch64-apple-darwin-dsymutil... no
checking for dsymutil... dsymutil
checking for aarch64-apple-darwin-nmedit... no
checking for nmedit... nmedit
checking for aarch64-apple-darwin-lipo... no
checking for lipo... lipo
checking for aarch64-apple-darwin-otool... no
checking for otool... otool
checking for aarch64-apple-darwin-otool64... no
checking for otool64... no
checking for -single_module linker flag... yes
checking for -exported_symbols_list linker flag... yes
checking for -force_load linker flag... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... yes
checking for gcc option to produce PIC... -fno-common -DPIC
checking if gcc PIC flag -fno-common -DPIC works... yes
checking if gcc static flag -static works... no
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... darwin dyld
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... no
checking whether to build static libraries... yes
checking for aarch64-apple-darwin-gcc... gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking whether gcc understands -c and -o together... (cached) yes
checking dependency style of gcc... (cached) gcc3
checking whether ln -s works... yes
checking for unif01_CreateExternGenBits in -ltestu01... no
checking linker version script flag... unsupported
checking sys/ndir.h usability... no
checking sys/ndir.h presence... no
checking for sys/ndir.h... no
checking sys/dir.h usability... yes
checking sys/dir.h presence... yes
checking for sys/dir.h... yes
checking ndir.h usability... no
checking ndir.h presence... no
checking for ndir.h... no
checking dirent.h usability... yes
checking dirent.h presence... yes
checking for dirent.h... yes
checking grp.h usability... yes
checking grp.h presence... yes
checking for grp.h... yes
checking nlist.h usability... yes
checking nlist.h presence... yes
checking for nlist.h... yes
checking for inline... inline
checking for typeof syntax and keyword spelling... typeof
checking for int64_t... yes
checking for mode_t... yes
checking for off_t... yes
checking for pid_t... yes
checking for uid_t in sys/types.h... yes
checking for size_t... yes
checking for ssize_t... yes
checking whether F_CLOSEM is declared... no
checking for GNU .init_array section support... no
checking for program_invocation_short_name... no
checking for __progname... no
checking for __register_atfork... no
checking for clearenv... no
checking for dirfd... yes
checking for fopencookie... no
checking for __fpurge... no
checking for getauxval... no
checking for getentropy... yes
checking for getexecname... no
checking for getline... yes
checking for pstat_getproc... no
checking for sysconf... yes
checking for strlcpy... yes
checking for strlcat... yes
checking for strnstr... yes
checking for strmode... yes
checking for fpurge... yes
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating include/Makefile
config.status: creating man/Makefile
config.status: creating src/Makefile
config.status: creating src/libbsd.pc
config.status: creating src/libbsd-ctor.pc
config.status: creating src/libbsd-overlay.pc
config.status: creating test/Makefile
config.status: creating config.h
config.status: executing depfiles commands
config.status: executing libtool commands
/Applications/Xcode.app/Contents/Developer/usr/bin/make  all-recursive
Making all in include
make[2]: Nothing to be done for `all'.
Making all in man
make[2]: Nothing to be done for `all'.
Making all in src
  CC       arc4random_uniform.lo
  CC       arc4random.lo
  CC       bsd_getopt.lo
  CC       closefrom.lo
  CC       err.lo
  CC       dehumanize_number.lo
  CC       expand_number.lo
  CC       explicit_bzero.lo
  CC       fgetln.lo
  CC       fgetwln.lo
  CC       flopen.lo
  CC       fparseln.lo
  CC       fmtcheck.lo
  CC       fpurge.lo
  CC       funopen.lo
  CC       getbsize.lo
  CC       getpeereid.lo
  CC       heapsort.lo
  CC       humanize_number.lo
  CC       inet_net_pton.lo
  CC       nlist.lo
  CC       merge.lo
  CC       pidfile.lo
  CC       progname.lo
  CC       radixsort.lo
  CC       readpassphrase.lo
  CC       reallocarray.lo
  CC       reallocf.lo
  CC       setmode.lo
  CC       setproctitle.lo
  CC       strlcat.lo
  CC       strlcpy.lo
  CC       stringlist.lo
  CC       strmode.lo
  CC       strnstr.lo
  CC       strtoi.lo
  CC       strtonum.lo
  CC       strtou.lo
  CC       timeconv.lo
  CC       unvis.lo
  CC       vis.lo
  CC       wcslcat.lo
  CC       wcslcpy.lo
  CC       getentropy.lo
  CC       hash/md5.lo
  CC       hash/md5hl.lo
  CC       hash/sha512c.lo
../source_subfolder/src/hash/sha512c.c:62:3: error: implicit declaration of function 'be64enc' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
                be64enc(dst + i * 8, src[i]);
                ^
../source_subfolder/src/hash/sha512c.c:75:12: error: implicit declaration of function 'be64dec' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
                dst[i] = be64dec(src + i * 8);
                         ^
2 errors generated.
make[2]: *** [hash/sha512c.lo] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
libbsd/0.10.0: 
libbsd/0.10.0: ERROR: Package '68e2a114b5f505b6553899369b5c9590a42898d7' build failed
libbsd/0.10.0: WARN: Build folder /Users/syl/.conan/data/libbsd/0.10.0/_/_/build/68e2a114b5f505b6553899369b5c9590a42898d7
ERROR: libbsd/0.10.0: Error in build() method, line 66
	autotools.make()
	ConanException: Error 2 while executing make -j8
```

</details>



Discussion:
libbsd does not officially support macos.
It builds now, because the patch https://gitlab.freedesktop.org/libbsd/libbsd/-/merge_requests/3 is added.

Can you try adding the following in libbsd's conanfile (in `_configure_autotools`? (untested)
```python
if tools.is_apple_os(self.settings.os):
    self._autotools.flags.append("-Wno-error=implicit-function-declaration")
```

I think it would also be nice to add a comment to https://gitlab.freedesktop.org/libbsd/libbsd/-/merge_requests/3 mentioning your problem.
Perhaps its creator knows how to fix your problem.
libbsd does not compile on Mac (Intel) too. The error is the same. This is because  <machine/endian.h> on macOS does not contain the be64enc definition. 

> ./source_subfolder/src/hash/sha512c.c:62:3: error: implicit declaration of
      function 'be64enc' is invalid in C99
      [-Werror,-Wimplicit-function-declaration]
                be64enc(dst + i * 8, src[i]);
Have you tried my suggestion?
Me? No, I do not use libbsd at all. It will compile with your changes and will probably work on macOS too. But it's better when libbsd maintainers fix this issue. 

I meant to ask, did it compile, link and did the `test_package` compile/work?
I just tried your changes, libbsd compiles now. No idea how to try test_package.

>libbsd/0.10.0 package(): Packaged 1 file: COPYING
libbsd/0.10.0 package(): Packaged 26 '.h' files
libbsd/0.10.0 package(): Packaged 1 '.a' file: libbsd.a
libbsd/0.10.0: Package '647afeb69d3b0a2d3d316e80b24d38c714cc6900' created
libbsd/0.10.0: Created package revision 0907fb0c7c3665f4c0994407407233f4

Apply the changes to `recipes/libbsd/all/conanfile.py` and run `conan create recipes/libbsd/all libbsd/0.10.0@`.
The test package will automatically run.

Will you open a pr with the fix?

Resolving patch:
diff --git a/recipes/libbsd/all/conanfile.py b/recipes/libbsd/all/conanfile.py
--- a/recipes/libbsd/all/conanfile.py
+++ b/recipes/libbsd/all/conanfile.py
@@ -48,6 +48,8 @@ def _configure_autotools(self):
         if self._autotools:
             return self._autotools
         self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows)
+        if tools.is_apple_os(self.settings.os):
+            self._autotools.flags.append("-Wno-error=implicit-function-declaration")
         conf_args = [
         ]
         if self.options.shared:


Test patch: