- 
                Notifications
    You must be signed in to change notification settings 
- Fork 13.9k
          Migrate dump-ice-to-disk and panic-abort-eh_frame run-make tests to rmake
          #127523
        
          New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Merged
      
      
    
  
     Merged
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            2 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      
    File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              This file was deleted.
      
      Oops, something went wrong.
      
    
  This file was deleted.
      
      Oops, something went wrong.
      
    
  
            File renamed without changes.
          
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| // This test checks if internal compilation error (ICE) log files work as expected. | ||
| // - Get the number of lines from the log files without any configuration options, | ||
| // then check that the line count doesn't change if the backtrace gets configured to be short | ||
| // or full. | ||
| // - Check that disabling ICE logging results in zero files created. | ||
| // - Check that the ICE files contain some of the expected strings. | ||
| // See https://github.com/rust-lang/rust/pull/108714 | ||
|  | ||
| use run_make_support::{cwd, has_extension, has_prefix, rfs, rustc, shallow_find_files}; | ||
|  | ||
| fn main() { | ||
| rustc().input("lib.rs").arg("-Ztreat-err-as-bug=1").run_fail(); | ||
| let default = get_text_from_ice(".").lines().count(); | ||
| clear_ice_files(); | ||
|  | ||
| rustc().env("RUSTC_ICE", cwd()).input("lib.rs").arg("-Ztreat-err-as-bug=1").run_fail(); | ||
| let ice_text = get_text_from_ice(cwd()); | ||
| let default_set = ice_text.lines().count(); | ||
| let content = ice_text; | ||
| let ice_files = shallow_find_files(cwd(), |path| { | ||
| has_prefix(path, "rustc-ice") && has_extension(path, "txt") | ||
| }); | ||
| assert_eq!(ice_files.len(), 1); // There should only be 1 ICE file. | ||
| let ice_file_name = | ||
| ice_files.first().and_then(|f| f.file_name()).and_then(|n| n.to_str()).unwrap(); | ||
| // Ensure that the ICE dump path doesn't contain `:`, because they cause problems on Windows. | ||
| assert!(!ice_file_name.contains(":"), "{ice_file_name}"); | ||
|  | ||
| clear_ice_files(); | ||
| rustc() | ||
| .env("RUSTC_ICE", cwd()) | ||
| .input("lib.rs") | ||
| .env("RUST_BACKTRACE", "short") | ||
| .arg("-Ztreat-err-as-bug=1") | ||
| .run_fail(); | ||
| let short = get_text_from_ice(cwd()).lines().count(); | ||
| clear_ice_files(); | ||
| rustc() | ||
| .env("RUSTC_ICE", cwd()) | ||
| .input("lib.rs") | ||
| .env("RUST_BACKTRACE", "full") | ||
| .arg("-Ztreat-err-as-bug=1") | ||
| .run_fail(); | ||
| let full = get_text_from_ice(cwd()).lines().count(); | ||
| clear_ice_files(); | ||
|  | ||
| // The ICE dump is explicitly disabled. Therefore, this should produce no files. | ||
| rustc().env("RUSTC_ICE", "0").input("lib.rs").arg("-Ztreat-err-as-bug=1").run_fail(); | ||
| let ice_files = shallow_find_files(cwd(), |path| { | ||
| has_prefix(path, "rustc-ice") && has_extension(path, "txt") | ||
| }); | ||
| assert!(ice_files.is_empty()); // There should be 0 ICE files. | ||
|  | ||
| // The line count should not change. | ||
| assert_eq!(short, default_set); | ||
| assert_eq!(short, default); | ||
| assert_eq!(full, default_set); | ||
| assert!(default > 0); | ||
| // Some of the expected strings in an ICE file should appear. | ||
| assert!(content.contains("thread 'rustc' panicked at")); | ||
| assert!(content.contains("stack backtrace:")); | ||
| } | ||
|  | ||
| fn clear_ice_files() { | ||
| let ice_files = shallow_find_files(cwd(), |path| { | ||
| has_prefix(path, "rustc-ice") && has_extension(path, "txt") | ||
| }); | ||
| for file in ice_files { | ||
| rfs::remove_file(file); | ||
| } | ||
| } | ||
|  | ||
| #[track_caller] | ||
| fn get_text_from_ice(dir: impl AsRef<std::path::Path>) -> String { | ||
| let ice_files = | ||
| shallow_find_files(dir, |path| has_prefix(path, "rustc-ice") && has_extension(path, "txt")); | ||
| assert_eq!(ice_files.len(), 1); // There should only be 1 ICE file. | ||
| let ice_file = ice_files.get(0).unwrap(); | ||
| let output = rfs::read_to_string(ice_file); | ||
| output | ||
| } | 
This file was deleted.
      
      Oops, something went wrong.
      
    
  
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| // An `.eh_frame` section in an object file is a symptom of an UnwindAction::Terminate | ||
| // being inserted, useful for determining whether or not unwinding is necessary. | ||
| // This is useless when panics would NEVER unwind due to -C panic=abort. This section should | ||
| // therefore never appear in the emit file of a -C panic=abort compilation, and this test | ||
| // checks that this is respected. | ||
| // See https://github.com/rust-lang/rust/pull/112403 | ||
|  | ||
| //@ only-linux | ||
| // FIXME(Oneirical): the DW_CFA symbol appears on Windows-gnu, because uwtable | ||
| // is forced to true on Windows targets (see #128136). | ||
|  | ||
| use run_make_support::{llvm_objdump, rustc}; | ||
|  | ||
| fn main() { | ||
| rustc() | ||
| .input("foo.rs") | ||
| .crate_type("lib") | ||
| .emit("obj=foo.o") | ||
| .panic("abort") | ||
| .edition("2021") | ||
| .arg("-Zvalidate-mir") | ||
| .run(); | ||
| llvm_objdump().arg("--dwarf=frames").input("foo.o").run().assert_stdout_not_contains("DW_CFA"); | ||
| } | 
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.