Skip to content

Commit

Permalink
Fix setting of FR_LIBRARY_PATH
Browse files Browse the repository at this point in the history
to be relative to the location of jlibtool.  Not to the binary that
we're running.  If the binary is "lldb", then it doesn't help us find
$(BUILD_DIR)/lib/local/.libs

Revert "Revert "ensure that we automatically point to the correct libdir""

This reverts commit 8ea864c.
  • Loading branch information
alandekok committed May 16, 2020
1 parent 4ed829b commit 2914837
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 32 deletions.
43 changes: 17 additions & 26 deletions scripts/jlibtool.c
Expand Up @@ -104,7 +104,7 @@
# define ADD_MINUS_L
# define LD_RUN_PATH "LD_RUN_PATH"
# define LD_LIBRARY_PATH "LD_LIBRARY_PATH"
# define LD_LIBRARY_PATH_LOCAL LD_LIBRARY_PATH
# define LD_LIBRARY_PATH_LOCAL "LD_LIBRARY_PATH"
#endif

#if defined(__sun) && !defined(__GNUC__)
Expand All @@ -126,7 +126,7 @@
# define HAS_REALPATH
# define LD_RUN_PATH "LD_RUN_PATH"
# define LD_LIBRARY_PATH "LD_LIBRARY_PATH"
# define LD_LIBRARY_PATH_LOCAL LD_LIBRARY_PATH
# define LD_LIBRARY_PATH_LOCAL "LD_LIBRARY_PATH"
#endif

#if defined(_OSD_POSIX)
Expand Down Expand Up @@ -160,7 +160,7 @@
# define NEED_SNPRINTF
# define LD_RUN_PATH "LD_RUN_PATH"
# define LD_LIBRARY_PATH "LD_LIBRARY_PATH"
# define LD_LIBRARY_PATH_LOCAL LD_LIBRARY_PATH
# define LD_LIBRARY_PATH_LOCAL "LD_LIBRARY_PATH"
#endif

#if defined(__MINGW32__)
Expand Down Expand Up @@ -329,6 +329,7 @@ static void add_rpath(count_chars *cc, char const *path);
#endif

static pid_t spawn_pid;
char const *program = NULL;

static void usage(int code)
{
Expand Down Expand Up @@ -2328,32 +2329,21 @@ static int run_mode(command_t *cmd)
goto finish;
}

if (strlen(cmd->arglist->vals[0]) >= PATH_MAX) {
ERROR("Libpath too long no buffer space\n");
rv = 1;
/*
* jlibtool is in $(BUILD_DIR)/make/jlibtool
*/
strcpy(libpath, program);

goto finish;
}
/*
* Libraries are relative to jlibtool, in
* $(BUILD_DIR)/lib/local/.libs/
*/
l = strstr(libpath, "/make");
if (l) strcpy(l, "/lib/local/.libs");

strcpy(libpath, cmd->arglist->vals[0]);
add_dotlibs(libpath);
#if 0
l = strrchr(libpath, '/');
if (!l) l = strrchr(libpath, '\\');
if (l) {
*l = '\0';
l = libpath;
} else {
l = ".libs/";
}
#endif
setenv(LD_LIBRARY_PATH_LOCAL, libpath, 1);
setenv("FR_LIBRARY_PATH", libpath, 1);

l = "./build/lib/local/.libs";
setenv(LD_LIBRARY_PATH_LOCAL, l, 1);
#ifdef __APPLE__
setenv("DYLD_FALLBACK_LIBRARY_PATH", l, 1);
#endif
setenv("FR_LIBRARY_PATH", "./build/lib/local/.libs", 1);
rv = run_command(cmd, cmd->arglist);
if (rv) goto finish;
}
Expand Down Expand Up @@ -2710,6 +2700,7 @@ int main(int argc, char *argv[])
int rc;
command_t cmd;

program = argv[0];
memset(&cmd, 0, sizeof(cmd));

cmd.options.pic_mode = PIC_UNKNOWN;
Expand Down
12 changes: 6 additions & 6 deletions scripts/libtool.mk
Expand Up @@ -48,10 +48,10 @@ ifeq "${LIBTOOL}" "JLIBTOOL"

jlibtool: ${JLIBTOOL}

clean: jlibtool_clean
clean: clean.jlibtool

.PHONY: jlibtool_clean
jlibtool_clean:
.PHONY: clean.jlibtool
clean.jlibtool:
$(Q)rm -f ${JLIBTOOL}

# Tell GNU Make to use this value, rather than anything specified
Expand All @@ -62,10 +62,10 @@ endif # else we're not using jlibtool
# When using libtool, it produces a '.libs' directory. Ensure that it
# is removed on "make clean", too.
#
clean: .libs_clean
clean: clean.libs

.PHONY: .libs_clean
.libs_clean:
.PHONY: clean.libs
clean.libs:
$(Q)rm -rf ${BUILD_DIR}/.libs/

# Re-define compilers and linkers
Expand Down

0 comments on commit 2914837

Please sign in to comment.