@@ -51,6 +51,14 @@ use std::thread;
51
51
52
52
const PRE_LTO_BC_EXT : & str = "pre-lto.bc" ;
53
53
54
+ /// The kind of bitcode to embed in object files.
55
+ #[ derive( PartialEq ) ]
56
+ pub enum EmbedBitcode {
57
+ None ,
58
+ Marker ,
59
+ Full ,
60
+ }
61
+
54
62
/// Module-specific configuration for `optimize_and_codegen`.
55
63
pub struct ModuleConfig {
56
64
/// Names of additional optimization passes to run.
@@ -93,8 +101,7 @@ pub struct ModuleConfig {
93
101
// emscripten's ecc compiler, when used as the linker.
94
102
pub obj_is_bitcode : bool ,
95
103
pub no_integrated_as : bool ,
96
- pub embed_bitcode : bool ,
97
- pub embed_bitcode_marker : bool ,
104
+ pub embed_bitcode : EmbedBitcode ,
98
105
}
99
106
100
107
impl ModuleConfig {
@@ -119,8 +126,7 @@ impl ModuleConfig {
119
126
emit_asm : false ,
120
127
emit_obj : false ,
121
128
obj_is_bitcode : false ,
122
- embed_bitcode : false ,
123
- embed_bitcode_marker : false ,
129
+ embed_bitcode : EmbedBitcode :: None ,
124
130
no_integrated_as : false ,
125
131
126
132
verify_llvm_ir : false ,
@@ -143,16 +149,15 @@ impl ModuleConfig {
143
149
self . new_llvm_pass_manager = sess. opts . debugging_opts . new_llvm_pass_manager ;
144
150
self . obj_is_bitcode =
145
151
sess. target . target . options . obj_is_bitcode || sess. opts . cg . linker_plugin_lto . enabled ( ) ;
146
- let embed_bitcode =
147
- sess. target . target . options . embed_bitcode || sess. opts . debugging_opts . embed_bitcode ;
148
- if embed_bitcode {
149
- match sess. opts . optimize {
150
- config:: OptLevel :: No | config:: OptLevel :: Less => {
151
- self . embed_bitcode_marker = embed_bitcode;
152
+ self . embed_bitcode =
153
+ if sess. target . target . options . embed_bitcode || sess. opts . debugging_opts . embed_bitcode {
154
+ match sess. opts . optimize {
155
+ config:: OptLevel :: No | config:: OptLevel :: Less => EmbedBitcode :: Marker ,
156
+ _ => EmbedBitcode :: Full ,
152
157
}
153
- _ => self . embed_bitcode = embed_bitcode ,
154
- }
155
- }
158
+ } else {
159
+ EmbedBitcode :: None
160
+ } ;
156
161
157
162
// Copy what clang does by turning on loop vectorization at O2 and
158
163
// slp vectorization at O3. Otherwise configure other optimization aspects
@@ -188,7 +193,10 @@ impl ModuleConfig {
188
193
}
189
194
190
195
pub fn bitcode_needed ( & self ) -> bool {
191
- self . emit_bc || self . obj_is_bitcode || self . emit_bc_compressed || self . embed_bitcode
196
+ self . emit_bc
197
+ || self . obj_is_bitcode
198
+ || self . emit_bc_compressed
199
+ || self . embed_bitcode == EmbedBitcode :: Full
192
200
}
193
201
}
194
202
0 commit comments