Skip to content

Commit 2f0401e

Browse files
committed
fix macos tcc header lookup
1 parent b0e03b2 commit 2f0401e

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

vlib/v/builder/cbuilder/parallel_cc.v

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,16 +80,22 @@ fn parallel_cc(mut b builder.Builder, result c.GenOutput) ! {
8080
mut compile_args := b.get_compile_args()
8181
mut linker_args := b.get_linker_args()
8282
if b.ccoptions.cc == .tcc {
83-
// vlang/tcc has its system headers under `${vroot}/thirdparty/tcc/lib/tcc/include/`
84-
// and its runtime objects (libtcc1.a, bt-*.o) under `${vroot}/thirdparty/tcc/lib/tcc/`.
83+
// vlang/tcc can have its system headers and runtime objects either under
84+
// `${vroot}/thirdparty/tcc/lib/tcc/` or directly under `${vroot}/thirdparty/tcc/lib/`.
8585
// `-B` controls tcc's include search (`${B}/include`) and `-L` adds a library search path,
8686
// so pass absolute paths for both. This lets tcc find them regardless of the cwd from
8787
// which v was invoked, without affecting how user-supplied relative flags are resolved.
88-
tcc_install_dir := os.join_path(@VEXEROOT, 'thirdparty', 'tcc', 'lib', 'tcc')
88+
tcc_lib_dir := os.join_path(@VEXEROOT, 'thirdparty', 'tcc', 'lib')
89+
tcc_nested_dir := os.join_path(tcc_lib_dir, 'tcc')
90+
tcc_install_dir := if os.is_dir(tcc_nested_dir) { tcc_nested_dir } else { tcc_lib_dir }
8991
if os.is_dir(tcc_install_dir) {
9092
tcc_b_arg := '-B${b.tcc_quoted_path(tcc_install_dir)}'
9193
tcc_l_arg := '-L${b.tcc_quoted_path(tcc_install_dir)}'
94+
tcc_include_dir := os.join_path(tcc_install_dir, 'include')
9295
compile_args << tcc_b_arg
96+
if os.is_dir(tcc_include_dir) {
97+
compile_args << '-I${b.tcc_quoted_path(tcc_include_dir)}'
98+
}
9399
linker_args << tcc_b_arg
94100
linker_args << tcc_l_arg
95101
}

vlib/v/gen/c/cheaders.v

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,7 @@ V_CRT_LINKAGE void * V_CRT_CALL malloc(size_t size);
572572
V_CRT_LINKAGE void * V_CRT_CALL calloc(size_t nitems, size_t size);
573573
V_CRT_LINKAGE void * V_CRT_CALL realloc(void *ptr, size_t size);
574574
V_CRT_LINKAGE void * V_CRT_CALL aligned_alloc(size_t alignment, size_t size);
575+
V_CRT_LINKAGE int V_CRT_CALL posix_memalign(void **memptr, size_t alignment, size_t size);
575576
V_CRT_LINKAGE void V_CRT_CALL free(void *ptr);
576577
V_CRT_LINKAGE int V_CRT_CALL rand(void);
577578
V_CRT_LINKAGE void V_CRT_CALL srand(unsigned int seed);

0 commit comments

Comments
 (0)