- 
                Notifications
    
You must be signed in to change notification settings  - Fork 13.9k
 
Support reading thin archives in ArArchiveBuilder #128936
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
          
          
            9 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      4f8042e
              
                Support reading thin archives in ArArchiveBuilder
              
              
                bjorn3 a57f73d
              
                Add test for thin archive reading support
              
              
                bjorn3 c1f5350
              
                Use ArArchiveBuilder with the LLVM backend too
              
              
                bjorn3 d63a067
              
                Add fixme for removing LlvmArchiveBuilder in the future
              
              
                bjorn3 db68a19
              
                Fix review comments and other improvements
              
              
                bjorn3 2217014
              
                Apply some suggestions to the test rmake file
              
              
                bjorn3 9de0d14
              
                Unconditionally use the LLVM symbol reader
              
              
                bjorn3 7c972d7
              
                Use toString instead of raw_svector_ostream for error messages
              
              
                bjorn3 901c9da
              
                Fix null pointer dereference when a file is not an object file
              
              
                bjorn3 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 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 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 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 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,5 @@ | ||
| fn main() { | ||
| unsafe { | ||
| rust_lib::simple_fn(); | ||
| } | ||
| } | 
  
    
      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,23 @@ | ||
| // Regression test for https://github.com/rust-lang/rust/issues/107407 which | ||
| // checks that rustc can read thin archive. Before the object crate added thin | ||
| // archive support rustc would add emit object files to the staticlib and after | ||
| // the object crate added thin archive support it would previously crash the | ||
| // compiler due to a missing special case for thin archive members. | ||
| use run_make_support::{llvm_ar, path, rfs, rust_lib_name, rustc, static_lib_name}; | ||
| 
     | 
||
| fn main() { | ||
| rfs::create_dir("archive"); | ||
| 
     | 
||
| // Build a thin archive | ||
| rustc().input("simple_obj.rs").emit("obj").output("archive/simple_obj.o").run(); | ||
| llvm_ar() | ||
| .obj_to_thin_ar() | ||
| .output_input(path("archive").join(static_lib_name("thin_archive")), "archive/simple_obj.o") | ||
| .run(); | ||
                
      
                  jieyouxu marked this conversation as resolved.
               
          
            Show resolved
            Hide resolved
         | 
||
| 
     | 
||
| // Build an rlib which includes the members of this thin archive | ||
| rustc().input("rust_lib.rs").library_search_path("archive").run(); | ||
| 
     | 
||
| // Build a binary which requires a symbol from the thin archive | ||
| rustc().input("bin.rs").extern_("rust_lib", rust_lib_name("rust_lib")).run(); | ||
| } | ||
  
    
      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,6 @@ | ||
| #![crate_type = "rlib"] | ||
| 
     | 
||
| #[link(name = "thin_archive", kind = "static")] | ||
| extern "C" { | ||
| pub fn simple_fn(); | ||
| } | 
  
    
      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,4 @@ | ||
| #![crate_type = "staticlib"] | ||
| 
     | 
||
| #[no_mangle] | ||
| extern "C" fn simple_fn() {} | 
  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.