@@ -507,46 +507,12 @@ impl<'ctx> WhitelistedItemsTraversal<'ctx> {
507
507
}
508
508
}
509
509
510
- const HOST_TARGET : & ' static str =
511
- include_str ! ( concat!( env!( "OUT_DIR" ) , "/host-target.txt" ) ) ;
512
-
513
- /// Returns the effective target, and whether it was explicitly specified on the
514
- /// clang flags.
515
- fn find_effective_target ( clang_args : & [ String ] ) -> ( String , bool ) {
516
- use std:: env;
517
-
518
- let mut args = clang_args. iter ( ) ;
519
- while let Some ( opt) = args. next ( ) {
520
- if opt. starts_with ( "--target=" ) {
521
- let mut split = opt. split ( '=' ) ;
522
- split. next ( ) ;
523
- return ( split. next ( ) . unwrap ( ) . to_owned ( ) , true ) ;
524
- }
525
-
526
- if opt == "-target" {
527
- if let Some ( target) = args. next ( ) {
528
- return ( target. clone ( ) , true ) ;
529
- }
530
- }
531
- }
532
-
533
- // If we're running from a build script, try to find the cargo target.
534
- if let Ok ( t) = env:: var ( "TARGET" ) {
535
- return ( t, false ) ;
536
- }
537
-
538
- ( HOST_TARGET . to_owned ( ) , false )
539
- }
540
-
541
510
impl BindgenContext {
542
511
/// Construct the context for the given `options`.
543
512
pub ( crate ) fn new ( options : BindgenOptions ) -> Self {
544
513
// TODO(emilio): Use the CXTargetInfo here when available.
545
514
//
546
515
// see: https://reviews.llvm.org/D32389
547
- let ( effective_target, explicit_target) =
548
- find_effective_target ( & options. clang_args ) ;
549
-
550
516
let index = clang:: Index :: new ( false , true ) ;
551
517
552
518
let parse_options =
@@ -555,26 +521,11 @@ impl BindgenContext {
555
521
let translation_unit = {
556
522
let _t =
557
523
Timer :: new ( "translation_unit" ) . with_output ( options. time_phases ) ;
558
- // NOTE: The effective_target == HOST_TARGET check wouldn't be sound
559
- // normally in some cases if we were to call a binary (if you have a
560
- // 32-bit clang and are building on a 64-bit system for example).
561
- // But since we rely on opening libclang.so, it has to be the same
562
- // architecture and thus the check is fine.
563
- let clang_args = if explicit_target ||
564
- effective_target == HOST_TARGET
565
- {
566
- Cow :: Borrowed ( & options. clang_args )
567
- } else {
568
- let mut args = Vec :: with_capacity ( options. clang_args . len ( ) + 1 ) ;
569
- args. push ( format ! ( "--target={}" , effective_target) ) ;
570
- args. extend_from_slice ( & options. clang_args ) ;
571
- Cow :: Owned ( args)
572
- } ;
573
524
574
525
clang:: TranslationUnit :: parse (
575
526
& index,
576
527
"" ,
577
- & clang_args,
528
+ & options . clang_args ,
578
529
& options. input_unsaved_files ,
579
530
parse_options,
580
531
) . expect ( "libclang error; possible causes include:
@@ -587,22 +538,6 @@ If you encounter an error missing from this list, please file an issue or a PR!"
587
538
} ;
588
539
589
540
let target_info = clang:: TargetInfo :: new ( & translation_unit) ;
590
-
591
- #[ cfg( debug_assertions) ]
592
- {
593
- if let Some ( ref ti) = target_info {
594
- if effective_target == HOST_TARGET {
595
- assert_eq ! (
596
- ti. pointer_width / 8 ,
597
- mem:: size_of:: <* mut ( ) >( ) ,
598
- "{:?} {:?}" ,
599
- effective_target,
600
- HOST_TARGET
601
- ) ;
602
- }
603
- }
604
- }
605
-
606
541
let root_module = Self :: build_root_module ( ItemId ( 0 ) ) ;
607
542
let root_module_id = root_module. id ( ) . as_module_id_unchecked ( ) ;
608
543
0 commit comments