Skip to content

Commit a5fbaef

Browse files
committed
Fix static linking in wrapper tools
1 parent 9dc8273 commit a5fbaef

File tree

4 files changed

+20
-9
lines changed

4 files changed

+20
-9
lines changed

clang/tools/nec-aurora-build/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ find_library(
3232
set(NECAURORA_STATIC_LINKING_AVAILABLE 1)
3333

3434
if (NECAURORA_LIBVEORUN_STATIC)
35-
set(LIBVEORUN_STATIC_PATH "${NECAURORA_LIBVEORUN_STATIC_LIBRARY}")
36-
set(NECAURORA_STATIC_LINKING_AVAILABLE 0)
35+
message(STATUS "Found libveorun.a")
36+
set(LIBVEORUN_STATIC_PATH "${NECAURORA_LIBVEORUN_STATIC}")
3737
endif()
3838

3939
find_package(NECAURORA_LIBELF)

clang/tools/nec-aurora-build/linker.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ std::string generateSymTabCode(const std::vector<std::string> &symbols) {
103103
}
104104

105105
int runStaticLinker(const std::vector<const char *> &ObjectFiles,
106-
const std::string &Args) {
106+
const std::string &Args, const std::string &OutputFile) {
107107
#ifndef LIBVEORUN_STATIC_PATH
108108
std::cerr << "necaurora-ofld-wrapper: Static linking not supported"
109109
<< std::endl;
@@ -118,9 +118,13 @@ int runStaticLinker(const std::vector<const char *> &ObjectFiles,
118118

119119
std::string SymTabPath = generateSymTabCode(SymbolNames);
120120

121-
CmdLine << getTargetCompiler() << " "
121+
CmdLine << getTargetCompiler() << " ";
122+
for (auto ObjFile: ObjectFiles) {
123+
CmdLine << ObjFile << " ";
124+
}
125+
CmdLine << SymTabPath << " "
122126
<< LIBVEORUN_STATIC_PATH
123-
<< " " << SymTabPath << " " << Args;
127+
<< " -fopenmp -o " << OutputFile;
124128
if (Verbose) {
125129
std::cerr << " \"" << CmdLine.str() << "\"" << std::endl;
126130
}

clang/tools/nec-aurora-build/necaurora-ofld-wrapper.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ enum class ToolMode {
4242

4343
int parseCmdline(int argc, char **argv, ToolMode &Mode, std::string &SotocPath,
4444
std::string &InputFile, std::string &Args, bool &Verbose,
45-
bool &SaveTemps, std::vector<const char *> &ObjectFiles) {
45+
bool &SaveTemps, std::vector<const char *> &ObjectFiles,
46+
std::string &OutputFile) {
4647
std::stringstream ArgsStream;
4748
Mode = ToolMode::Unknown;
4849
bool StaticLinkerFlag = false;
@@ -87,6 +88,10 @@ int parseCmdline(int argc, char **argv, ToolMode &Mode, std::string &SotocPath,
8788
ArgsStream << argv[i] << " ";
8889
ObjectFiles.push_back(argv[i]);
8990
continue;
91+
} else if (strcmp(argv[i], "-o") == 0) {
92+
ArgsStream << argv[i] << " ";
93+
OutputFile = std::string(argv[i+1]);
94+
continue;
9095
} else {
9196
ArgsStream << argv[i] << " ";
9297
}
@@ -131,11 +136,12 @@ int main(int argc, char **argv) {
131136
std::string SotocOutputPath;
132137
std::string Args;
133138
std::vector<const char *> ObjectFiles;
139+
std::string OutputFile;
134140

135141
KeepTransformedFilesDir = std::getenv("NECAURORA_KEEP_FILES_DIR");
136142

137143
rc = parseCmdline(argc, argv, Mode, SotocPath, InputFile, Args, Verbose,
138-
SaveTemps, ObjectFiles);
144+
SaveTemps, ObjectFiles, OutputFile);
139145
if (rc != 0) {
140146
std::cerr << "necaurora-ofld-cc1-wraper: failed parsing the command "
141147
<< "line\n";
@@ -161,7 +167,7 @@ int main(int argc, char **argv) {
161167
return EXIT_FAILURE;
162168
}
163169
} else if (Mode == ToolMode::StaticLinker) {
164-
rc = runStaticLinker(ObjectFiles, Args);
170+
rc = runStaticLinker(ObjectFiles, Args, OutputFile);
165171
if (rc != 0) {
166172
std::cerr << "necaurora-ofld-wrapper: static linking failed "
167173
<< "with code " << rc << "\n";

clang/tools/nec-aurora-build/necaurora-ofld-wrapper.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ int runSourceTransformation(const std::string &InputPath,
1717
int runTargetCompiler(const std::string &InputPath, const std::string &Args);
1818

1919
int runStaticLinker(const std::vector<const char *> &ObjectFiles,
20-
const std::string &Args);
20+
const std::string &Args,
21+
const std::string &OutputFile);
2122

2223
int runPassthrough(const std::string &Args);
2324

0 commit comments

Comments
 (0)