@@ -215,16 +215,19 @@ pub unsafe fn create_module<'ll>(
215
215
// to ensure intrinsic calls don't use it.
216
216
if !sess. needs_plt ( ) {
217
217
let avoid_plt = "RtLibUseGOT\0 " . as_ptr ( ) . cast ( ) ;
218
- llvm:: LLVMRustAddModuleFlag ( llmod, avoid_plt, 1 ) ;
218
+ llvm:: LLVMRustAddModuleFlag ( llmod, llvm :: LLVMModFlagBehavior :: Warning , avoid_plt, 1 ) ;
219
219
}
220
220
221
221
if sess. is_sanitizer_cfi_enabled ( ) {
222
222
// FIXME(rcvalle): Add support for non canonical jump tables.
223
223
let canonical_jump_tables = "CFI Canonical Jump Tables\0 " . as_ptr ( ) . cast ( ) ;
224
- // FIXME(rcvalle): Add it with Override behavior flag--LLVMRustAddModuleFlag adds it with
225
- // Warning behavior flag. Add support for specifying the behavior flag to
226
- // LLVMRustAddModuleFlag.
227
- llvm:: LLVMRustAddModuleFlag ( llmod, canonical_jump_tables, 1 ) ;
224
+ // FIXME(rcvalle): Add it with Override behavior flag.
225
+ llvm:: LLVMRustAddModuleFlag (
226
+ llmod,
227
+ llvm:: LLVMModFlagBehavior :: Warning ,
228
+ canonical_jump_tables,
229
+ 1 ,
230
+ ) ;
228
231
}
229
232
230
233
// Control Flow Guard is currently only supported by the MSVC linker on Windows.
@@ -233,11 +236,21 @@ pub unsafe fn create_module<'ll>(
233
236
CFGuard :: Disabled => { }
234
237
CFGuard :: NoChecks => {
235
238
// Set `cfguard=1` module flag to emit metadata only.
236
- llvm:: LLVMRustAddModuleFlag ( llmod, "cfguard\0 " . as_ptr ( ) as * const _ , 1 )
239
+ llvm:: LLVMRustAddModuleFlag (
240
+ llmod,
241
+ llvm:: LLVMModFlagBehavior :: Warning ,
242
+ "cfguard\0 " . as_ptr ( ) as * const _ ,
243
+ 1 ,
244
+ )
237
245
}
238
246
CFGuard :: Checks => {
239
247
// Set `cfguard=2` module flag to emit metadata and checks.
240
- llvm:: LLVMRustAddModuleFlag ( llmod, "cfguard\0 " . as_ptr ( ) as * const _ , 2 )
248
+ llvm:: LLVMRustAddModuleFlag (
249
+ llmod,
250
+ llvm:: LLVMModFlagBehavior :: Warning ,
251
+ "cfguard\0 " . as_ptr ( ) as * const _ ,
252
+ 2 ,
253
+ )
241
254
}
242
255
}
243
256
}
@@ -247,24 +260,28 @@ pub unsafe fn create_module<'ll>(
247
260
248
261
llvm:: LLVMRustAddModuleFlag (
249
262
llmod,
263
+ llvm:: LLVMModFlagBehavior :: Error ,
250
264
"branch-target-enforcement\0 " . as_ptr ( ) . cast ( ) ,
251
265
bti. into ( ) ,
252
266
) ;
253
267
254
268
llvm:: LLVMRustAddModuleFlag (
255
269
llmod,
270
+ llvm:: LLVMModFlagBehavior :: Error ,
256
271
"sign-return-address\0 " . as_ptr ( ) . cast ( ) ,
257
272
pac. is_some ( ) . into ( ) ,
258
273
) ;
259
274
let pac_opts = pac. unwrap_or ( PacRet { leaf : false , key : PAuthKey :: A } ) ;
260
275
llvm:: LLVMRustAddModuleFlag (
261
276
llmod,
277
+ llvm:: LLVMModFlagBehavior :: Error ,
262
278
"sign-return-address-all\0 " . as_ptr ( ) . cast ( ) ,
263
279
pac_opts. leaf . into ( ) ,
264
280
) ;
265
281
let is_bkey = if pac_opts. key == PAuthKey :: A { false } else { true } ;
266
282
llvm:: LLVMRustAddModuleFlag (
267
283
llmod,
284
+ llvm:: LLVMModFlagBehavior :: Error ,
268
285
"sign-return-address-with-bkey\0 " . as_ptr ( ) . cast ( ) ,
269
286
is_bkey. into ( ) ,
270
287
) ;
0 commit comments