Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kumir2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
2
Issues
2
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
kumir
kumir2
Commits
e9a8ba8e
Commit
e9a8ba8e
authored
Oct 20, 2014
by
Victor Yacovlev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Win32: Reverted back to LLVM 3.4.1 stack due to 3.5 does not work
parent
29b41d1e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
40 deletions
+60
-40
src/plugins/llvmcodegenerator/llvmcodegeneratorplugin.cpp
src/plugins/llvmcodegenerator/llvmcodegeneratorplugin.cpp
+60
-40
No files found.
src/plugins/llvmcodegenerator/llvmcodegeneratorplugin.cpp
View file @
e9a8ba8e
...
...
@@ -354,18 +354,21 @@ QString LLVMCodeGeneratorPlugin::findLibraryByName(const QString &baseName)
QByteArray
LLVMCodeGeneratorPlugin
::
runExternalToolsToGenerateExecutable
(
const
QByteArray
&
bitcode
)
{
#ifdef Q_OS_WIN32
#if LLVM_VERSION_MINOR != 4
#error "Windows version works only with LLVM 3.4 but not 3.5!"
#endif
static
const
QString
bundledToolchainPath
=
QDir
::
toNativeSeparators
(
QDir
::
cleanPath
(
QCoreApplication
::
applicationDirPath
()
+
"/../llvm-mingw/"
)
);
static
const
QString
LLC
=
bundledToolchainPath
+
"
\\
llc.exe"
;
static
const
QString
AS
=
bundledToolchainPath
+
"
\\
clang.exe"
;
// GNU as in most linux distros doesn't accept llvm-3.5 generated syntax
static
const
QString
AS
=
bundledToolchainPath
+
"
\\
as.exe"
;
static
const
QString
LD
=
bundledToolchainPath
+
"
\\
ld.exe"
;
#else
static
const
QString
LLC
=
"llc"
;
static
const
QString
AS
=
"clang"
;
// GNU as in most linux distros doesn't accept llvm-3.5 generated syntax
static
const
QString
LD
=
"clang"
;
// libstdc++ might have several names in Linux, use
GCC
to find it
static
const
QString
LD
=
"clang"
;
// libstdc++ might have several names in Linux, use
compiler
to find it
#endif
// ====== Write bitcode to external file
...
...
@@ -385,12 +388,27 @@ QByteArray LLVMCodeGeneratorPlugin::runExternalToolsToGenerateExecutable(const Q
QByteArray
output
;
QProcess
process
;
// ====== Compile bitcode to machine code using LLVM llc
QStringList
llcArguments
;
bool
skipSecondStage
=
false
;
if
(
LLC
.
contains
(
"clang"
))
{
// === Compile bitcode to object using CLang
skipSecondStage
=
true
;
llcArguments
=
QStringList
()
<<
"-c"
<<
"-O3"
<<
"-o"
<<
QDir
::
toNativeSeparators
(
objFileName
)
<<
QDir
::
toNativeSeparators
(
bcFileName
);
}
else
{
// ====== Compile bitcode to ASM code using LLVM llc
skipSecondStage
=
false
;
llcArguments
=
QStringList
()
<<
"-O3"
<<
"-o"
<<
QDir
::
toNativeSeparators
(
asmFileName
)
<<
QDir
::
toNativeSeparators
(
bcFileName
);
}
const
QStringList
llcArguments
=
QStringList
()
<<
"-O3"
<<
"-o"
<<
QDir
::
toNativeSeparators
(
asmFileName
)
<<
QDir
::
toNativeSeparators
(
bcFileName
);
#ifdef Q_OS_WIN32
process
.
setWorkingDirectory
(
bundledToolchainPath
);
#endif
...
...
@@ -421,42 +439,44 @@ QByteArray LLVMCodeGeneratorPlugin::runExternalToolsToGenerateExecutable(const Q
qApp
->
quit
();
}
// ====== Assemble object using GNU as
if
(
!
skipSecondStage
)
{
// ====== Assemble object using GNU as
QStringList
asArguments
=
QStringList
()
<<
"-o"
<<
QDir
::
toNativeSeparators
(
objFileName
)
<<
QDir
::
toNativeSeparators
(
asmFileName
);
if
(
AS
.
endsWith
(
"clang"
))
{
asArguments
.
prepend
(
"-c"
);
}
#ifdef Q_OS_WIN32
process
.
setWorkingDirectory
(
bundledToolchainPath
);
#endif
process
.
setProcessChannelMode
(
QProcess
::
MergedChannels
);
process
.
start
(
AS
,
asArguments
);
qDebug
()
<<
"Starting: "
<<
AS
<<
asArguments
;
if
(
!
process
.
waitForFinished
())
{
errorMessage
=
QString
(
"== ERROR == %1 %2 failed: %3"
)
.
arg
(
AS
)
.
arg
(
asArguments
.
join
(
" "
))
.
arg
(
process
.
errorString
())
;
}
else
{
output
=
process
.
readAllStandardOutput
()
+
"
\n
"
+
process
.
readAllStandardError
();
qDebug
()
<<
output
;
const
int
status
=
process
.
exitStatus
();
if
(
0
!=
status
)
{
errorMessage
=
QString
(
"== ERROR == %1 %2 exited with status: %3"
)
.
arg
(
AS
).
arg
(
asArguments
.
join
(
" "
)).
arg
(
status
);
QStringList
asArguments
=
QStringList
()
<<
"-o"
<<
QDir
::
toNativeSeparators
(
objFileName
)
<<
QDir
::
toNativeSeparators
(
asmFileName
);
if
(
AS
.
endsWith
(
"clang"
)
||
AS
.
endsWith
(
"clang.exe"
))
{
asArguments
.
prepend
(
"-c"
);
}
#ifdef Q_OS_WIN32
process
.
setWorkingDirectory
(
bundledToolchainPath
);
#endif
process
.
setProcessChannelMode
(
QProcess
::
MergedChannels
);
process
.
start
(
AS
,
asArguments
);
qDebug
()
<<
"Starting: "
<<
AS
<<
asArguments
;
if
(
!
process
.
waitForFinished
())
{
errorMessage
=
QString
(
"== ERROR == %1 %2 failed: %3"
)
.
arg
(
AS
)
.
arg
(
asArguments
.
join
(
" "
))
.
arg
(
process
.
errorString
())
;
}
else
{
output
=
process
.
readAllStandardOutput
()
+
"
\n
"
+
process
.
readAllStandardError
();
qDebug
()
<<
output
;
const
int
status
=
process
.
exitStatus
();
if
(
0
!=
status
)
{
errorMessage
=
QString
(
"== ERROR == %1 %2 exited with status: %3"
)
.
arg
(
AS
).
arg
(
asArguments
.
join
(
" "
)).
arg
(
status
);
}
}
}
if
(
errorMessage
.
length
()
>
0
)
{
std
::
cerr
<<
errorMessage
.
toStdString
()
<<
std
::
endl
;
qApp
->
setProperty
(
"returnCode"
,
5
);
qApp
->
quit
();
if
(
errorMessage
.
length
()
>
0
)
{
std
::
cerr
<<
errorMessage
.
toStdString
()
<<
std
::
endl
;
qApp
->
setProperty
(
"returnCode"
,
5
);
qApp
->
quit
();
}
}
// ====== Link executable using GNU ld
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment