From e90fbc90f3a064b8b9e749534c05ed9657ccecf9 Mon Sep 17 00:00:00 2001 From: Shreyas Khandekar <60454060+ShreyasKhandekar@users.noreply.github.com> Date: Thu, 10 Oct 2024 18:11:22 -0500 Subject: [PATCH 1/2] Make CHPL_LIB_PATH ignore empty strings If CHPL_LIB_PATH has colons in it, we split the path based on the colons. However, if we have a trailing or leading colon, or two colons back to back (`::`) in CHPL_LIB_PATH, it get's added as an empty string. This cases errors since there isn't an argument to go with `-L` for the target compiler. This makes the change such the the `addPath` function ignores the empty strings in CHPL_LIB_PATH. Signed-off-by: Shreyas Khandekar <60454060+ShreyasKhandekar@users.noreply.github.com> --- compiler/util/files.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/compiler/util/files.cpp b/compiler/util/files.cpp index d215ca9a3215..37780f0020dc 100644 --- a/compiler/util/files.cpp +++ b/compiler/util/files.cpp @@ -91,7 +91,23 @@ static void addPath(const char* pathVar, std::vector* pathvec) { colon++; // and advance to the next } - pathvec->push_back(astr(dirString)); + // FIXME (Maybe?) + // Following the precedent of $PATH on Unix, we should + // treat empty strings between colons like :: or trailing/leading + // colons as meaning to add the current directory to the path. + // If we don't include the current directory in the CHPL_LIB_PATH by + // default, this behavior below is incorrect, and instead of ignoring + // empty strings, it should figure out the current directory and add + // that to the path. + // Alternatively, we can alter the compiler to throw -L . when + // CHPL_LIB_PATH has empty strings in between colons. + // However, if we do include the current directory in CHPL_LIB_PATH + // by default, then this doesn't need fixing, delete this FIXME. + + // ignore empty strings + if (dirString && *dirString) { + pathvec->push_back(astr(dirString)); + } dirString = colon; // advance dirString } while (colon != NULL); From 41c3f13841158e8084226a7a24864a73556eacdb Mon Sep 17 00:00:00 2001 From: Shreyas Khandekar <60454060+ShreyasKhandekar@users.noreply.github.com> Date: Thu, 10 Oct 2024 19:17:41 -0500 Subject: [PATCH 2/2] Changes based on review Signed-off-by: Shreyas Khandekar <60454060+ShreyasKhandekar@users.noreply.github.com> --- compiler/util/files.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/util/files.cpp b/compiler/util/files.cpp index 37780f0020dc..4183614988d1 100644 --- a/compiler/util/files.cpp +++ b/compiler/util/files.cpp @@ -105,7 +105,7 @@ static void addPath(const char* pathVar, std::vector* pathvec) { // by default, then this doesn't need fixing, delete this FIXME. // ignore empty strings - if (dirString && *dirString) { + if (dirString && strlen(dirString) > 0) { pathvec->push_back(astr(dirString)); }