Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot use modules that use mbedtls on macos arm with tcc #21639

Open
ttytm opened this issue Jun 3, 2024 · 2 comments
Open

cannot use modules that use mbedtls on macos arm with tcc #21639

ttytm opened this issue Jun 3, 2024 · 2 comments
Labels
Boehm Garbage Collection (GC) Bugs/feature requests related to the Boehm garbage collector and its integration into V programs. Bug This tag is applied to issues which reports bugs. Compiler: TCC Bugs/feature requests, that are related to compiling V programs with TCC. OS: Mac Bugs/feature requests, that are specific to Mac OS.

Comments

@ttytm
Copy link
Member

ttytm commented Jun 3, 2024

Describe the bug

It's not possible to use modules that import the current version of mbedtls on macos arm

Reproduction Steps

// file.v
import net.http as _
v -cc tcc file.v

Expected Behavior

Compiles.

Current Behavior

failed thirdparty object build cmd:
'/Users/t/Dev/v_/thirdparty/tcc/tcc.exe' -std=c99 -D_DEFAULT_SOURCE   -fwrapv  -fPIC -I "/Users/t/Dev/v_/thirdparty/mbedtl
s/library" -I "/Users/t/Dev/v_/thirdparty/mbedtls/include" -I "/Users/t/Dev/v_/thirdparty/mbedtls/3rdparty/everest/include
" -I "/Users/t/Dev/v_/thirdparty/mbedtls/3rdparty/everest/include/everest" -I "/Users/t/Dev/v_/thirdparty/mbedtls/3rdparty
/everest/include/everest/kremlib" -o '/Users/t/.vmodules/cache/91/910b5681c4bc3aed814f8e89ae21bc5a.module.net.mbedtls.o' -
c '/Users/t/Dev/v_/thirdparty/mbedtls/library/bignum_core.c'
builder error: /Users/t/Dev/v_/thirdparty/mbedtls/library/bignum_core.c:441: error: ARM asm not implemented.

Possible Solution

Update tcc bins to allow updating mbedtls version. It would also allow to progress on pull/20726 and pull/20753

Additional Information/Context

No response

V version

Environment details (OS name and version, etc.)

V full version: V 0.4.6 19c08f5.cc92dbc
OS: macos, macOS, 14.4.1, 23E224
Processor: 8 cpus, 64bit, little endian, Apple M1

getwd: /Users/t/Nextcloud/Dev/vlang/playground
vexe: /Users/t/Dev/v_/v
vexe mtime: 2024-06-03 21:36:22

vroot: OK, value: /Users/t/Dev/v_
VMODULES: OK, value: /Users/t/.vmodules
VTMP: OK, value: /tmp/v_501

Git version: git version 2.45.1
Git vroot status: weekly.2024.22-34-gcc92dbc8
.git/config present: true

CC version: Apple clang version 15.0.0 (clang-1500.3.9.4)
thirdparty/tcc status: thirdparty-macos-arm64 5c1d002f-dirty

Note

You can use the 👍 reaction to increase the issue's priority for developers.

Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.

@ttytm ttytm added the Bug This tag is applied to issues which reports bugs. label Jun 3, 2024
@spytheman
Copy link
Member

Yes, it is a known problem. tcc does not yet support ARM asm blocks on macos.

The current workarounds are to either:
a) -cc clang for such programs, which is slower, but should work without other changes.
or
b) if you do not need mbedtls, but just net.http and net.ssl, pass -d use_openssl , which should work with tcc too (after installing openssl with brew).

@spytheman
Copy link
Member

spytheman commented Jun 8, 2024

Here is an example of compiling examples/fetch.v, which does use net.http:

0[07:19:44]@m1: (master) /opt/v $ ./v -showcc -d use_openssl -cc tcc -no-retry-compilation -d dynamic_boehm examples/fetch.v
> C compiler cmd: '/opt/v/thirdparty/tcc/tcc.exe' '@/tmp/v_501/fetch.01HZV160EXN887J1X6A9R7T7HZ.tmp.c.rsp'
> C compiler response file "/tmp/v_501/fetch.01HZV160EXN887J1X6A9R7T7HZ.tmp.c.rsp":
  -fwrapv -o "/opt/v/examples/fetch" -D GC_THREADS=1 -I "/opt/homebrew/Cellar/bdw-gc/8.2.4/include" -L "/opt/homebrew/Cellar/bdw-gc/8.2.4/lib" -I "/opt/v/thirdparty/legacy/include/LegacySupport" -I "/opt/v/thirdparty/stdatomic/nix" -I "/opt/homebrew/Cellar/openssl@3/3.3.0/include" -L "/opt/homebrew/Cellar/openssl@3/3.3.0/lib" "/tmp/v_501/fetch.01HZV160EXN887J1X6A9R7T7HZ.tmp.c" -std=c99 -D_DEFAULT_SOURCE -bt25 -lgc -lpthread -lssl -lcrypto
0[07:19:52]@m1: (master) /opt/v $
0[07:19:53]@m1: (master) /opt/v $

The -d dynamic_boehm is needed to get V to use the brew version of the precompiled Boehm collector, since tcc can not link to our libgc.a too.

@spytheman spytheman added OS: Mac Bugs/feature requests, that are specific to Mac OS. Compiler: TCC Bugs/feature requests, that are related to compiling V programs with TCC. Boehm Garbage Collection (GC) Bugs/feature requests related to the Boehm garbage collector and its integration into V programs. labels Jun 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Boehm Garbage Collection (GC) Bugs/feature requests related to the Boehm garbage collector and its integration into V programs. Bug This tag is applied to issues which reports bugs. Compiler: TCC Bugs/feature requests, that are related to compiling V programs with TCC. OS: Mac Bugs/feature requests, that are specific to Mac OS.
Projects
None yet
Development

No branches or pull requests

2 participants