[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Tinycc-devel] rc testing with netbsd-curses: build break
From: |
Detlef Riekenberg |
Subject: |
Re: [Tinycc-devel] rc testing with netbsd-curses: build break |
Date: |
Fri, 22 Sep 2023 21:17:22 +0200 |
--
Bye bye ... Detlef
> > libcurses/libcurses.so: error: referenced dll 'libterminfo.so' not found
> > make: *** [GNUmakefile:529: libpanel/libpanel.so] Fehler 1
> > * libpanel/libpanel.so depends on libcurses/libcurses.so
> > * libcurses/libcurses.so depends on libterminfo/libterminfo.so
> > * tcc searches for libterminfo.so, but fails
>
> That happened to get into my way too at some point.
> Obviously when loading a .so library,
> tcc additionally is loads its dependencies too.
That would be correct, when the target is TCC_OUTPUT_MEMORY
but i think, in all other cases, tcc should not do that.
> It's rather early code, at tccelf.c:3653
>
> /* load all referenced DLLs */
> for(i = 0, dt = dynamic; i < nb_dts; i++, dt++) {
> switch(dt->d_tag) {
> case DT_NEEDED:
> ...
> What's the point isn't entirely clear to me.
The point here is, that tcc tries to load all referenced libraries,
which is wrong.
> Normally if one wants to use symbols from say libterminfo too
> one could just write -lcurses -lterminfo.
"-lterminfo" is wrong, as the affected code (libpanel.so)
has no reference to "libterminfo.so" but needs only "libcurses.so".
The fact, that "libcurses.so" depends on "libterminfo.so" is an implementation
detail.
Transformed to windows:
The Program needs kernel32.dll, but that kernel32.dll depends on ntdll.dll
is also an implementation detail.
> There may be three options:
> 1) downgrade the error to a warning,
> 2) disable loading of referenced DLLs completely,
> 3) have some switch to choose behavior
(if such exists in gcc for example)
#1: tcc still tries to load DT_NEEDED libraries.
#3: gcc builds libpanel.so without any fancy switch
I think, "2" is the only correct fix.
I don't know the tcc callchain good enough to say,
in which codepath lands in tccelf.c:3658
Do you think, that making tccelf.c:3658 to tccelf.c:3661
depend on is enough?
At least, that fixes the compilation break.
$ git diff tccelf.c | tee 0000_avoid_recursive_lib_loading.txt
diff --git a/tccelf.c b/tccelf.c
index 2e3d8ac..31b1b16 100644
--- a/tccelf.c
+++ b/tccelf.c
@@ -3655,9 +3655,13 @@ ST_FUNC int tcc_load_dll(TCCState *s1, int fd, const
char *filename, int level)
name = dynstr + dt->d_un.d_val;
if (tcc_add_dllref(s1, name, -1))
continue;
- if (tcc_add_dll(s1, name, AFF_REFERENCED_DLL) < 0) {
- ret = tcc_error_noabort("referenced dll '%s' not found", name);
- goto the_end;
+
+ if (s1->output_type == TCC_OUTPUT_MEMORY) {
+ /* TODO: check, when this code is reached/needed */
+ if (tcc_add_dll(s1, name, AFF_REFERENCED_DLL) < 0) {
+ ret = tcc_error_noabort("referenced dll '%s' not found",
name);
+ goto the_end;
+ }
}
}
}
--
Regards ... Detlef