Hi,
I've recently cloned tinycc to explore the project and probably hack inside
some features and I found some trouble loading the libc.
I'm on nixos and so the path of the libc is generally under
`/nix/store/<some long hash>`.
So I have two choices, 1. call the configure script with the libpaths
argument. 2. Link with an argument running tcc. But wouldn't it be more
convenient to load the LD_LIBRARY_PATH when it detects `nostdlib_paths` to
be false?
It looks odd but the following patch worked for me. If you have any
suggestions I would enjoy exchanging with you.
Best regards,
Adrien
---
diff --git a/libtcc.c b/libtcc.c
index b9bd9f57..70af0178 100644
--- a/libtcc.c
+++ b/libtcc.c
@@ -66,6 +66,8 @@
#include "tcc.h"
+#include <stdlib.h>
+
/********************************************************/
/* global variables */
@@ -980,8 +982,12 @@ LIBTCCAPI int tcc_set_output_type(TCCState *s, int
output_type)
return 0;
}
- if (!s->nostdlib_paths)
+ if (!s->nostdlib_paths) {
+ char *ld_library_path_env = getenv("LD_LIBRARY_PATH");
+ if (ld_library_path_env != NULL)
+ tcc_add_library_path(s, ld_library_path_env);
tcc_add_library_path(s, CONFIG_TCC_LIBPATHS);
+ }
#ifdef TCC_TARGET_PE
# ifdef TCC_IS_NATIVE
_______________________________________________
Tinycc-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel