Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DIVINE
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
paradise
mirror
DIVINE
Commits
d108ae7e
There was an error fetching the commit references. Please try again later.
Commit
d108ae7e
authored
6 years ago
by
Zuzana Baranová
Browse files
Options
Downloads
Patches
Plain Diff
tools: Factor divcc's compile{,_and_link} out of main().
parent
c1474199
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tools/divcc.cpp
+48
-34
48 additions, 34 deletions
tools/divcc.cpp
with
48 additions
and
34 deletions
tools/divcc.cpp
+
48
−
34
View file @
d108ae7e
#include
<divine/cc/cc1.hpp>
#include
<divine/cc/cc1.hpp>
#include
<divine/cc/options.hpp>
#include
<divine/rt/dios-cc.hpp>
#include
<divine/rt/dios-cc.hpp>
#include
<divine/rt/runtime.hpp>
#include
<divine/rt/runtime.hpp>
#include
<divine/vm/xg-code.hpp>
#include
<divine/vm/xg-code.hpp>
...
@@ -27,6 +28,7 @@ static const std::string bcsec = ".llvmbc";
...
@@ -27,6 +28,7 @@ static const std::string bcsec = ".llvmbc";
using
namespace
divine
;
using
namespace
divine
;
using
namespace
llvm
;
using
namespace
llvm
;
using
PairedFiles
=
std
::
vector
<
std
::
pair
<
std
::
string
,
std
::
string
>
>
;
void
addSection
(
std
::
string
filepath
,
std
::
string
sectionName
,
const
std
::
string
&
sectionData
)
void
addSection
(
std
::
string
filepath
,
std
::
string
sectionName
,
const
std
::
string
&
sectionData
)
...
@@ -125,7 +127,7 @@ bool isType( std::string file, cc::FileType type )
...
@@ -125,7 +127,7 @@ bool isType( std::string file, cc::FileType type )
return
cc
::
typeFromFile
(
file
)
==
type
;
return
cc
::
typeFromFile
(
file
)
==
type
;
}
}
std
::
unique_ptr
<
llvm
::
Module
>
llvmExtract
(
std
::
vector
<
std
::
pair
<
std
::
string
,
std
::
string
>
>
&
files
,
cc
::
CC1
&
clang
)
std
::
unique_ptr
<
llvm
::
Module
>
llvmExtract
(
PairedFiles
&
files
,
cc
::
CC1
&
clang
)
{
{
using
FileType
=
cc
::
FileType
;
using
FileType
=
cc
::
FileType
;
using
namespace
brick
::
types
;
using
namespace
brick
::
types
;
...
@@ -172,6 +174,48 @@ std::unique_ptr< llvm::Module > llvmExtract( std::vector< std::pair< std::string
...
@@ -172,6 +174,48 @@ std::unique_ptr< llvm::Module > llvmExtract( std::vector< std::pair< std::string
return
m
;
return
m
;
}
}
int
compile
(
cc
::
ParsedOpts
&
po
,
cc
::
CC1
&
clang
,
PairedFiles
&
objFiles
)
{
using
FileType
=
cc
::
FileType
;
for
(
auto
file
:
objFiles
)
{
if
(
isType
(
file
.
first
,
FileType
::
Obj
)
||
isType
(
file
.
first
,
FileType
::
Archive
)
)
continue
;
auto
mod
=
clang
.
compile
(
file
.
first
,
po
.
opts
);
emitObjFile
(
*
mod
,
file
.
second
);
}
return
0
;
}
int
compile_and_link
(
cc
::
ParsedOpts
&
po
,
cc
::
CC1
&
clang
,
PairedFiles
&
objFiles
)
{
using
FileType
=
cc
::
FileType
;
std
::
string
s
;
for
(
auto
file
:
objFiles
)
{
if
(
isType
(
file
.
first
,
FileType
::
Obj
)
||
isType
(
file
.
first
,
FileType
::
Archive
)
)
{
s
+=
file
.
first
+
" "
;
continue
;
}
std
::
string
ofn
=
file
.
second
;
auto
mod
=
clang
.
compile
(
file
.
first
,
po
.
opts
);
emitObjFile
(
*
mod
,
ofn
);
s
+=
ofn
+
" "
;
}
if
(
po
.
outputFile
!=
""
)
s
+=
" -o "
+
po
.
outputFile
;
s
.
insert
(
0
,
"gcc "
);
s
.
append
(
" -static"
);
int
gccret
=
system
(
s
.
c_str
()
);
return
WEXITSTATUS
(
gccret
);
}
/* usage: same as gcc */
/* usage: same as gcc */
int
main
(
int
argc
,
char
**
argv
)
int
main
(
int
argc
,
char
**
argv
)
...
@@ -180,7 +224,7 @@ int main( int argc, char **argv )
...
@@ -180,7 +224,7 @@ int main( int argc, char **argv )
cc
::
CC1
clang
;
cc
::
CC1
clang
;
clang
.
allowIncludePath
(
"/"
);
clang
.
allowIncludePath
(
"/"
);
divine
::
rt
::
each
(
[
&
](
auto
path
,
auto
c
)
{
clang
.
mapVirtualFile
(
path
,
c
);
}
);
divine
::
rt
::
each
(
[
&
](
auto
path
,
auto
c
)
{
clang
.
mapVirtualFile
(
path
,
c
);
}
);
std
::
vector
<
std
::
pair
<
std
::
string
,
std
::
string
>
>
objFiles
;
PairedFiles
objFiles
;
std
::
vector
<
std
::
string
>
opts
;
std
::
vector
<
std
::
string
>
opts
;
std
::
copy
(
argv
+
1
,
argv
+
argc
,
std
::
back_inserter
(
opts
)
);
std
::
copy
(
argv
+
1
,
argv
+
argc
,
std
::
back_inserter
(
opts
)
);
...
@@ -243,39 +287,9 @@ int main( int argc, char **argv )
...
@@ -243,39 +287,9 @@ int main( int argc, char **argv )
int
ret
=
0
;
int
ret
=
0
;
if
(
po
.
toObjectOnly
)
if
(
po
.
toObjectOnly
)
{
return
compile
(
po
,
clang
,
objFiles
);
for
(
auto
file
:
objFiles
)
{
if
(
isType
(
file
.
first
,
FileType
::
Obj
)
||
isType
(
file
.
first
,
FileType
::
Archive
)
)
continue
;
auto
mod
=
clang
.
compile
(
file
.
first
,
po
.
opts
);
emitObjFile
(
*
mod
,
file
.
second
);
}
return
0
;
}
else
else
{
ret
=
compile_and_link
(
po
,
clang
,
objFiles
);
std
::
string
s
;
for
(
auto
file
:
objFiles
)
{
if
(
isType
(
file
.
first
,
FileType
::
Obj
)
||
isType
(
file
.
first
,
FileType
::
Archive
)
)
{
s
+=
file
.
first
+
" "
;
continue
;
}
std
::
string
ofn
=
file
.
second
;
auto
mod
=
clang
.
compile
(
file
.
first
,
po
.
opts
);
emitObjFile
(
*
mod
,
ofn
);
s
+=
ofn
+
" "
;
}
if
(
po
.
outputFile
!=
""
)
s
+=
" -o "
+
po
.
outputFile
;
s
.
insert
(
0
,
"gcc "
);
s
.
append
(
" -static"
);
int
gccret
=
system
(
s
.
c_str
()
);
ret
=
WEXITSTATUS
(
gccret
);
}
if
(
!
ret
)
if
(
!
ret
)
{
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment