tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] Compile Libbtc for Apple M1 with tcc


From: Niklas Rosencrantz
Subject: Re: [Tinycc-devel] Compile Libbtc for Apple M1 with tcc
Date: Tue, 11 Jan 2022 12:55:24 +0100

After applying that commit, it went further to a
tcc: error: unsupported linker option '-undefined'

It's when I tried to build that specific project ( Libbtc ) https://github.com/libbtc/libbtc
that says it's ANSI C, with x86_64 Apple macOS system so it's the same with both Intel and M1 Apples. It complained about endianness as well, then after applying your commit there's a linker message

  CCLD     libsecp256k1.la
warning: /Library/Developer/CommandLineTools/usr/bin/ranlib: archive library: .libs/libsecp256k1.a the table of contents is empty (no object file members in the library define global symbols)
  CCLD     libbtc.la
tcc: error: unsupported linker option '-undefined'
make[1]: *** [libbtc.la] Error 1
make: *** [all-recursive] Error 1

More information what happened

% tcc -v
tcc version 0.9.27 mob:4e0e9b8 (x86_64 Darwin)
niklrose@Admins-MBP libbtc % ./configure CC=tcc
checking build system type... x86_64-apple-darwin21.2.0
checking host system type... x86_64-apple-darwin21.2.0
checking whether make supports nested variables... yes
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a race-free mkdir -p... ./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 the include directive... yes (GNU style)
checking for gcc... tcc
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... no
checking for suffix of object files... o
checking whether the compiler supports GNU C... yes
checking whether tcc accepts -g... yes
checking for tcc option to enable C11 features... unsupported
checking for tcc option to enable C99 features... none needed
checking whether tcc understands -c and -o together... yes
checking dependency style of tcc... tcc
checking for stdio.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for strings.h... yes
checking for sys/stat.h... yes
checking for sys/types.h... yes
checking for unistd.h... yes
checking for _Bool... yes
checking for stdbool.h that conforms to C99... yes
checking how to print strings... printf
checking for a sed that does not truncate output... /usr/bin/sed
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for fgrep... /usr/bin/grep -F
checking for ld used by tcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... no
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) 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-darwin21.2.0 file names to x86_64-apple-darwin21.2.0 format... func_convert_file_noop
checking how to convert x86_64-apple-darwin21.2.0 file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for ar... ar
checking for archiver @FILE support... no
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from tcc 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 mt... no
checking if : is a manifest tool... no
checking for dsymutil... dsymutil
checking for nmedit... nmedit
checking for lipo... lipo
checking for otool... otool
checking for otool64... no
checking for -single_module linker flag... tcc: error: unsupported linker option '-single_module'
no
checking for -exported_symbols_list linker flag... no
checking for -force_load linker flag... tcc: error: unsupported linker option '-force_load,./libconftest.a'
no
checking for dlfcn.h... yes
checking for objdir... .libs
checking if tcc supports -fno-rtti -fno-exceptions... yes
checking for tcc option to produce PIC... -fno-common -DPIC
checking if tcc PIC flag -fno-common -DPIC works... yes
checking if tcc static flag -static works... no
checking if tcc supports -c -o file.o... yes
checking if tcc supports -c -o file.o... (cached) yes
checking whether the tcc linker (/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... darwin21.2.0 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... yes
checking whether to build static libraries... yes
checking for pkg-config... /usr/local/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for ar... /usr/bin/ar
checking for ranlib... /usr/bin/ranlib
checking for strip... /usr/bin/strip
checking if tcc supports -std=gnu99 -pedantic -Wno-unused-function -Wno-long-long -Wno-overlength-strings -Werror=return-type... yes
checking for __builtin_expect... yes
checking for event2/event.h... yes
checking for main in -levent_core... yes
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating libbtc.pc
config.status: creating src/libbtc-config.h
config.status: src/libbtc-config.h is unchanged
config.status: executing depfiles commands
config.status: executing libtool commands
=== configuring in src/secp256k1 (/Users/niklrose/proj/libbtc/libbtc/src/secp256k1)
configure: running /bin/sh ./configure --disable-option-checking '--prefix=/usr/local'  'CC=tcc' '--enable-module-recovery' --cache-file=/dev/null --srcdir=.
checking build system type... x86_64-apple-darwin21.2.0
checking host system type... x86_64-apple-darwin21.2.0
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a race-free mkdir -p... ./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 how to print strings... printf
checking whether make supports the include directive... yes (GNU style)
checking for gcc... tcc
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... no
checking for suffix of object files... o
checking whether the compiler supports GNU C... yes
checking whether tcc accepts -g... yes
checking for tcc option to enable C11 features... unsupported
checking for tcc option to enable C99 features... none needed
checking whether tcc understands -c and -o together... yes
checking dependency style of tcc... tcc
checking for a sed that does not truncate output... /usr/bin/sed
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for fgrep... /usr/bin/grep -F
checking for ld used by tcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... no
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) 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-darwin21.2.0 file names to x86_64-apple-darwin21.2.0 format... func_convert_file_noop
checking how to convert x86_64-apple-darwin21.2.0 file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for ar... ar
checking for archiver @FILE support... no
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from tcc 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 mt... no
checking if : is a manifest tool... no
checking for dsymutil... dsymutil
checking for nmedit... nmedit
checking for lipo... lipo
checking for otool... otool
checking for otool64... no
checking for -single_module linker flag... tcc: error: unsupported linker option '-single_module'
no
checking for -exported_symbols_list linker flag... no
checking for -force_load linker flag... tcc: error: unsupported linker option '-force_load,./libconftest.a'
no
checking for stdio.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for strings.h... yes
checking for sys/stat.h... yes
checking for sys/types.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if tcc supports -fno-rtti -fno-exceptions... yes
checking for tcc option to produce PIC... -fno-common -DPIC
checking if tcc PIC flag -fno-common -DPIC works... yes
checking if tcc static flag -static works... no
checking if tcc supports -c -o file.o... yes
checking if tcc supports -c -o file.o... (cached) yes
checking whether the tcc linker (/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... darwin21.2.0 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... yes
checking whether to build static libraries... yes
checking whether make supports nested variables... (cached) yes
checking for pkg-config... /usr/local/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for ar... /usr/bin/ar
checking for ranlib... /usr/bin/ranlib
checking for strip... /usr/bin/strip
checking dependency style of tcc... tcc
checking for brew... /usr/local/bin/brew
checking if tcc supports -std=c89 -pedantic -Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wstrict-prototypes -Wundef -Wno-unused-function -Wno-long-long -Wno-overlength-strings... yes
checking if tcc supports -fvisibility=hidden... yes
checking for valgrind/memcheck.h... no
checking for x86_64 assembly availability... no
checking for libcrypto... no
checking for openssl/crypto.h... no
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating libsecp256k1.pc
config.status: creating src/libsecp256k1-config.h
config.status: src/libsecp256k1-config.h is unchanged
config.status: executing depfiles commands
config.status: executing libtool commands

Build Options:
  with ecmult precomp     = yes
  with external callbacks = no
  with benchmarks         = yes
  with tests              = yes
  with openssl tests      = no
  with coverage           = no
  module ecdh             = no
  module recovery         = yes
  module extrakeys        = no
  module schnorrsig       = no

  asm                     = no
  ecmult window size      = 15
  ecmult gen prec. bits   = 4

  valgrind                = no
  CC                      = tcc
  CFLAGS                  = -O2 -fvisibility=hidden -std=c89 -pedantic -Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wstrict-prototypes -Wundef -Wno-unused-function -Wno-long-long -Wno-overlength-strings -W -g
  CPPFLAGS                = -I/usr/local/opt/valgrind/include
  LDFLAGS                 =

  CC_FOR_BUILD            = tcc
  CFLAGS_FOR_BUILD        = -O2 -fvisibility=hidden -std=c89 -pedantic -Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wstrict-prototypes -Wundef -Wno-unused-function -Wno-long-long -Wno-overlength-strings -W -g
  CPPFLAGS_FOR_BUILD      = -I/usr/local/opt/valgrind/include
  LDFLAGS_FOR_BUILD       =

Options used to compile and link:
  with wallet   = yes
  with tools    = yes
  with net      = yes

  target os     = darwin

  CC            = tcc
  CFLAGS        = -g -O2 -W -std=gnu99 -pedantic -Wno-unused-function -Wno-long-long -Wno-overlength-strings -Werror=return-type
  CXX           =
  CXXFLAGS      =
  LDFLAGS       =

niklrose@Admins-MBP libbtc % make
  CC       src/tools/bitcointool-bitcointool.o
  CC       src/libbtc_la-base58.lo
  CC       src/libbtc_la-bip32.lo
  CC       src/libbtc_la-block.lo
  CC       src/libbtc_la-commontools.lo
  CC       src/libbtc_la-ecc_key.lo
  CC       src/libbtc_la-ecc_libsecp256k1.lo
  CC       src/libbtc_la-script.lo
  CC       src/libbtc_la-tx.lo
  CC       src/trezor-crypto/libbtc_la-base58.lo
  CC       src/trezor-crypto/libbtc_la-blake2b.lo
  CC       src/trezor-crypto/libbtc_la-blake256.lo
  CC       src/trezor-crypto/libbtc_la-groestl.lo
  CC       src/trezor-crypto/libbtc_la-hasher.lo
  CC       src/trezor-crypto/libbtc_la-hmac.lo
  CC       src/trezor-crypto/libbtc_la-ripemd160.lo
  CC       src/trezor-crypto/libbtc_la-sha2.lo
  CC       src/trezor-crypto/libbtc_la-sha3.lo
  CC       src/logdb/libbtc_la-logdb_core.lo
  CC       src/logdb/libbtc_la-logdb_memdb_llist.lo
  CC       src/logdb/libbtc_la-logdb_memdb_rbtree.lo
  CC       src/logdb/libbtc_la-logdb_rec.lo
  CC       src/libbtc_la-wallet.lo
  CC       src/libbtc_la-headersdb_file.lo
  CC       src/libbtc_la-net.lo
  CC       src/libbtc_la-netspv.lo
  CC       src/libbtc_la-protocol.lo
  CC       src/libsecp256k1_la-secp256k1.lo
  CCLD     libsecp256k1.la
warning: /Library/Developer/CommandLineTools/usr/bin/ranlib: archive library: .libs/libsecp256k1.a the table of contents is empty (no object file members in the library define global symbols)
  CCLD     libbtc.la
tcc: error: unsupported linker option '-undefined'
make[1]: *** [libbtc.la] Error 1
make: *** [all-recursive] Error 1


On Tue, Jan 11, 2022 at 8:45 AM Niklas Rosencrantz <niklasro@gmail.com> wrote:
Thank you. I'll try it a.s.a.p.

The reason I don't try the change immediately is that I use my own experimental branch of TCC on my Apple M1.
I installed it on the system for educational purposes. 

It might work to do ./configure CC=/tmp/path_to_mod_tcc/tcc but I didn't try to install several versions.
TCC has been competent for me on Apple M1. TCC could compile itself on Apple M1 with the cpu=x86_64 configuration.

Regards,
Niklas



On Tue, Jan 11, 2022 at 7:12 AM Christian Jullien <eligis@orange.fr> wrote:
>
> Hi, tcc port on Apple M1 is not too bad as long as you accept it generates code for x86_64 which is then translated by rosetta.
>
> That said, your problem is that tcc does not define __LITTLE_ENDIAN__ as gcc does
>
> jullien@mobley:~ $ tcc -dM -E - < /dev/null | grep END | sort
> #define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
> #define __ORDER_BIG_ENDIAN__ 4321
> #define __ORDER_LITTLE_ENDIAN__ 1234
>
> jullien@mobley:~ $ gcc -dM -E - < /dev/null | grep END | sort
> #define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
> #define __LITTLE_ENDIAN__ 1
> #define __ORDER_BIG_ENDIAN__ 4321
> #define __ORDER_LITTLE_ENDIAN__ 1234
> #define __ORDER_PDP_ENDIAN__ 3412
>
> You can see that __LITTLE_ENDIAN__ is missing for tcc
>
> I've just added this missing definition on mod, you can test it right now.
>
> C.
>
> -----Original Message-----
> From: Tinycc-devel [mailto:tinycc-devel-bounces+eligis=orange.fr@nongnu.org] On Behalf Of david.koch@libertysurf.fr
> Sent: Tuesday, January 11, 2022 03:48
> To: tinycc-devel@nongnu.org
> Subject: [Tinycc-devel] Re : Compile Libbtc for Apple M1 with tcc
>
> Hi, the M1 chip is an ARM64 processor, not a x86_64 one.
>
> Perhaps the ARM support of TCC is not up to par with its x86 counterpart.
>
> Good luck anyway.
>
> Regards.
>
> ----- Mail d'origine -----
> De: Niklas Rosencrantz <niklasro@gmail.com>
> À: tinycc-devel@nongnu.org
> Envoyé: Mon, 10 Jan 2022 23:49:04 +0100 (CET)
> Objet: [Tinycc-devel] Compile Libbtc for Apple M1 with tcc
>
> Hello,
>
> Trying to compile Libbtc for Apple M1 with tcc. It worked with an Apple
> Intel machine and setting CC=tcc. Since tcc can build it on the Intel with
> macOS I try ask here if you might know the cause of the failure. With the
> Apple M1 the following message comes from make
>
> In file included from ./include/btc/serialize.h:34:
> In file included from ./include/btc/portable_endian.h:22:
> /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/libkern/OSByteOrder.h:314:
> error: #error Unknown endianess.
> make[1]: *** [src/tools/bitcointool-bitcointool.o] Error 1
>
>
> Build Options:
>   with ecmult precomp     = yes
>   with external callbacks = no
>   with benchmarks         = yes
>   with tests              = yes
>   with openssl tests      = no
>   with coverage           = no
>   module ecdh             = no
>   module recovery         = yes
>   module extrakeys        = no
>   module schnorrsig       = no
>
>   asm                     = no
>   ecmult window size      = 15
>   ecmult gen prec. bits   = 4
>
>   valgrind                = no
>   CC                      = tcc
>   CFLAGS                  = -O2 -fvisibility=hidden -std=c89 -pedantic
> -Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wstrict-prototypes
> -Wundef -Wno-unused-function -Wno-long-long -Wno-overlength-strings -W -g
>   CPPFLAGS                = -I/opt/homebrew/opt/valgrind/include
>   LDFLAGS                 =
>
>   CC_FOR_BUILD            = tcc
>   CFLAGS_FOR_BUILD        = -O2 -fvisibility=hidden -std=c89 -pedantic
> -Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wstrict-prototypes
> -Wundef -Wno-unused-function -Wno-long-long -Wno-overlength-strings -W -g
>   CPPFLAGS_FOR_BUILD      = -I/opt/homebrew/opt/valgrind/include
>   LDFLAGS_FOR_BUILD       =
>
> Options used to compile and link:
>   with wallet   = yes
>   with tools    = yes
>   with net      = yes
>
>   target os     = darwin
>
>   CC            = tcc
>   CFLAGS        = -g -O2 -W -std=gnu99 -pedantic -Wno-unused-function
> -Wno-long-long -Wno-overlength-strings -Werror=return-type
>   CXX           =
>   CXXFLAGS      =
>   LDFLAGS       =
>
>
> _______________________________________________
> Tinycc-devel mailing list
> Tinycc-devel@nongnu.org
> https://lists.nongnu.org/mailman/listinfo/tinycc-devel
>
>
> _______________________________________________
> Tinycc-devel mailing list
> Tinycc-devel@nongnu.org
> https://lists.nongnu.org/mailman/listinfo/tinycc-devel

reply via email to

[Prev in Thread] Current Thread [Next in Thread]