-
Notifications
You must be signed in to change notification settings - Fork 427
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20385 from mppf/move-override-ld-printchplenv
Move override-ld to printchplenv This PR addresses a future work item left by PR #18880. In particular, historically we have saved the linker to use in a file `override-ld` and then the LLVM backend reads this file and uses the selected linker in order to link the binary. We recently observed some problems with this strategy in the context of Homebrew. The Homebrew Chapel package had this `override-ld` file referring to clang in a particular location; but the Homebrew clang package was upgraded and clang was no longer available at that location. (See also Homebrew/homebrew-core#107405 ). So, this PR moves the `override-ld` logic to something supported by the chplenv Python scripts. One wrinkle with that is that the Makefile logic was using `GASNET_LD_REQUIRES_MPI` but that variable is not stored in the Gasnet .pc file that is used by the chplenv scripts in LLVM compilation. So, this PR uses the approximation of determining `GASNET_LD_REQUIRES_MPI` by searching for `mpi` in the `GASNET_LD` command name. Additionally, while debugging the issue, I noticed some odd things about the error handling within `executeAndWait`, so this PR cleans that function up a bit as well. It also removes some arguments to that function that aren't really necessary. It adds a C++ dyno test of this function to make sure the return value of the function is 0 when the command runs and something other than 0 when the command does not exist. The chpl-env-gen.h needed some adjustment to work with this change so I tidied it up to stop filtering out environment variables that often have characters that can't be in a `#define` and instead to use a more comprehensive pattern when replacing such characters with `_`. Future Work: * include https://bitbucket.org/berkeleylab/gasnet/pull-requests/554 in our bundled GASNet to actually use `GASNET_LD_REQUIRES_MPI` in the logic to match the previous behavior. Reviewed by @arezaii - [x] full local testing - [x] XC gasnet+aries testing - [x] XC ugni testing - [x] XC mpi testing - [x] Mac OS X testing - [x] testing Hello world on a real ibv system
- Loading branch information
Showing
15 changed files
with
348 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
/* | ||
* Copyright 2021-2022 Hewlett Packard Enterprise Development LP | ||
* Other additional copyright holders may be indicated within. | ||
* | ||
* The entirety of this work is licensed under the Apache License, | ||
* Version 2.0 (the "License"); you may not use this file except | ||
* in compliance with the License. | ||
* | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include "chpl/util/subprocess.h" | ||
|
||
#include <cassert> | ||
|
||
// always check assertions in this test | ||
#ifdef NDEBUG | ||
#undef NDEBUG | ||
#endif | ||
|
||
using namespace chpl; | ||
|
||
// check that trying to run a nonexistant command returns an error | ||
static void checkNonexistent() { | ||
int rc; | ||
std::vector<std::string> cmd; | ||
|
||
cmd.clear(); | ||
cmd.push_back("./nonexistent-command"); | ||
rc = executeAndWait(cmd, "nonexistent-command description", true); | ||
assert(rc != 0); | ||
|
||
cmd.clear(); | ||
cmd.push_back("./nonexistent-command"); | ||
cmd.push_back("arg"); | ||
rc = executeAndWait(cmd, "nonexistent-command description", true); | ||
assert(rc != 0); | ||
|
||
cmd.clear(); | ||
cmd.push_back("/this/path/does/not/exist"); | ||
rc = executeAndWait(cmd, "path does not exist description", true); | ||
assert(rc != 0); | ||
|
||
cmd.clear(); | ||
cmd.push_back("/this/path/does/not/exist"); | ||
cmd.push_back("arg"); | ||
rc = executeAndWait(cmd, "path does not exist description", true); | ||
assert(rc != 0); | ||
} | ||
|
||
// check that we can run /usr/bin/env and get 0 return code from it | ||
static void checkEnv() { | ||
int rc; | ||
std::vector<std::string> cmd; | ||
|
||
cmd.clear(); | ||
cmd.push_back("/usr/bin/env"); | ||
rc = executeAndWait(cmd, "testing that env can be run", true); | ||
assert(rc == 0); | ||
} | ||
|
||
// check that running an empty command or a comment returns 0 | ||
static void checkEmptyOrComment() { | ||
int rc; | ||
std::vector<std::string> cmd; | ||
|
||
cmd.clear(); | ||
rc = executeAndWait(cmd, "empty command 1", true); | ||
assert(rc == 0); | ||
|
||
cmd.clear(); | ||
cmd.push_back(""); | ||
rc = executeAndWait(cmd, "empty command 2", true); | ||
assert(rc == 0); | ||
|
||
cmd.clear(); | ||
cmd.push_back("# this is a comment"); | ||
rc = executeAndWait(cmd, "comment command", true); | ||
assert(rc == 0); | ||
} | ||
|
||
|
||
int main(int argc, char** argv) { | ||
|
||
checkNonexistent(); | ||
checkEnv(); | ||
checkEmptyOrComment(); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.