- 
                Notifications
    You must be signed in to change notification settings 
- Fork 15k
[flang][Driver] Enable -pie and -no-pie in flang's driver #164890
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
          
          
            5 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      81802aa
              
                [flang][Driver] Enable -pie and -no-pie in flang's driver
              
              
                tarunprabhu 312a7ee
              
                Address reviewer comments
              
              
                 94722a3
              
                Add tests where -no-pie and -pie are both present. Also add tests for…
              
              
                tarunprabhu 3f79259
              
                Add more tests for the defaults and expected behavior on a range of p…
              
              
                tarunprabhu 283cf81
              
                Also check for an unused argument warning on certain platforms
              
              
                tarunprabhu 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
          Some comments aren't visible on the classic Files Changed page.
        
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
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| ! Make sure that `-l` is "visible" to Flang's driver | ||
| ! RUN: %flang -lpgmath -### %s | ||
|  | ||
| ! Make sure that `-Wl` is "visible" to Flang's driver | ||
| ! RUN: %flang -Wl,abs -### %s | ||
|  | ||
| ! Make sure that `-fuse-ld' is "visible" to Flang's driver | ||
| ! RUN: %flang -fuse-ld= -### %s | ||
|  | ||
| ! Make sure that `-L' is "visible" to Flang's driver | ||
| ! RUN: %flang -L/ -### %s | ||
|  | ||
| ! ------------------------------------------------------------------------------ | ||
| ! Check that '-pie' and '-no-pie' are "visible" to Flang's driver. Check that | ||
| ! the correct option is added to the link line. | ||
| ! | ||
| ! Last match "wins" | ||
| ! RUN: %flang -target x86_64-pc-linux-gnu -pie -no-pie -### %s 2>&1 \ | ||
| ! RUN: | FileCheck %s --check-prefix=NO-PIE | ||
| ! RUN: %flang -target x86_64-pc-linux-gnu -no-pie -pie -### %s 2>&1 \ | ||
| ! RUN: | FileCheck %s --check-prefix=PIE | ||
| ! RUN: %flang -target x86_64-pc-linux-gnu -pie -### %s 2>&1 \ | ||
| ! RUN: | FileCheck %s --check-prefix=PIE | ||
| ! RUN: %flang -target x86_64-pc-linux-gnu -no-pie -### %s 2>&1 \ | ||
| ! RUN: | FileCheck %s --check-prefix=NO-PIE | ||
| ! | ||
| ! Ensure that "-pie" is passed to the linker. | ||
| ! RUN: %flang -target i386-unknown-freebsd -pie -### %s 2>&1 \ | ||
| ! RUN: | FileCheck %s --check-prefix=PIE | ||
| ! RUN: %flang -target aarch64-pc-linux-gnu -pie -### %s 2>&1 \ | ||
| ! RUN: | FileCheck %s --check-prefix=PIE | ||
| ! | ||
| ! On Musl Linux, PIE is enabled by default, but can be disabled. | ||
| ! RUN: %flang -target x86_64-linux-musl -### %s 2>&1 \ | ||
| ! RUN: | FileCheck %s --check-prefix=PIE | ||
| ! RUN: %flang -target i686-linux-musl -### %s 2>&1 \ | ||
| ! RUN: | FileCheck %s --check-prefix=PIE | ||
| ! RUN: %flang -target armv6-linux-musleabihf %s -### 2>&1 \ | ||
| ! RUN: | FileCheck %s --check-prefix=PIE | ||
| ! RUN: %flang -target armv7-linux-musleabihf %s -### 2>&1 \ | ||
| ! RUN: | FileCheck %s --check-prefix=PIE | ||
| ! RUN: %flang --target=x86_64-linux-musl -no-pie -### 2>&1 \ | ||
| ! RUN: | FileCheck %s --check-prefix=NO-PIE | ||
| ! | ||
| ! On OpenBSD, -pie is not passed to the linker, but can be forced. | ||
| ! RUN: %flang -target amd64-pc-openbsd -### %s 2>&1 \ | ||
| ! RUN: | FileCheck %s --check-prefix=NO-PIE | ||
| ! RUN: %flang -target i386-pc-openbsd -### %s 2>&1 \ | ||
| ! RUN: | FileCheck %s --check-prefix=NO-PIE | ||
| ! RUN: %flang -target aarch64-unknown-openbsd -### %s 2>&1 \ | ||
| ! RUN: | FileCheck %s --check-prefix=NO-PIE | ||
| ! RUN: %flang -target arm-unknown-openbsd -### %s 2>&1 \ | ||
| ! RUN: | FileCheck %s --check-prefix=NO-PIE | ||
| ! RUN: %flang -target powerpc-unknown-openbsd -### %s 2>&1 \ | ||
| ! RUN: | FileCheck %s --check-prefix=NO-PIE | ||
| ! RUN: %flang -target sparc64-unknown-openbsd -### %s 2>&1 \ | ||
| ! RUN: | FileCheck %s --check-prefix=NO-PIE | ||
| ! RUN: %flang -target i386-pc-openbsd -pie -### %s 2>&1 \ | ||
| ! RUN: | FileCheck %s --check-prefix=PIE | ||
| ! | ||
| ! On FreeBSD, -pie is not passed to the linker, but can be forced. | ||
| ! RUN: %flang -target amd64-pc-freebsd -### %s 2>&1 \ | ||
| ! RUN: | FileCheck %s --check-prefix=NO-PIE | ||
| ! RUN: %flang -target i386-pc-freebsd -### %s 2>&1 \ | ||
| ! RUN: | FileCheck %s --check-prefix=NO-PIE | ||
| ! RUN: %flang -target aarch64-unknown-freebsd -### %s 2>&1 \ | ||
| ! RUN: | FileCheck %s --check-prefix=NO-PIE | ||
| ! RUN: %flang -target arm-unknown-freebsd -### %s 2>&1 \ | ||
| ! RUN: | FileCheck %s --check-prefix=NO-PIE | ||
| ! RUN: %flang -target powerpc-unknown-freebsd -### %s 2>&1 \ | ||
| ! RUN: | FileCheck %s --check-prefix=NO-PIE | ||
| ! RUN: %flang -target sparc64-unknown-freebsd -### %s 2>&1 \ | ||
| ! RUN: | FileCheck %s --check-prefix=NO-PIE | ||
| ! RUN: %flang -target i386-pc-freebsd -pie -### %s 2>&1 \ | ||
| ! RUN: | FileCheck %s --check-prefix=PIE | ||
| ! | ||
| ! On AIX, -pie is never passed to the linker. | ||
| ! RUN: %flang -target powerpc64-unknown-aix -### %s 2>&1 \ | ||
| ! RUN: | FileCheck %s --check-prefixes=NO-PIE | ||
| ! RUN: %flang -target powerpc64-unknown-aix -pie -### %s 2>&1 \ | ||
| ! RUN: | FileCheck %s --check-prefixes=NO-PIE,UNUSED | ||
| ! RUN: %flang -target powerpc64-unknown-aix -no-pie -### %s 2>&1 \ | ||
| ! RUN: | FileCheck %s --check-prefixes=NO-PIE,UNUSED | ||
| ! | ||
| ! On MinGW and Windows, -pie may be specified, but it is ignored. | ||
|         
                  tarunprabhu marked this conversation as resolved.
              Show resolved
            Hide resolved | ||
| ! RUN: %flang -target aarch64-pc-windows-gnu -### %s 2>&1 \ | ||
| ! RUN: | FileCheck %s --check-prefixes=NO-PIE | ||
| ! RUN: %flang -target x86_64-pc-windows-gnu -pie -### %s 2>&1 \ | ||
| ! RUN: | FileCheck %s --check-prefixes=NO-PIE,UNUSED | ||
| ! RUN: %flang -target i686-pc-windows-gnu -no-pie -### %s 2>&1 \ | ||
| ! RUN: | FileCheck %s --check-prefixes=NO-PIE,UNUSED | ||
| ! RUN: %flang -target aarch64-windows-msvc -### %s 2>&1 \ | ||
| ! RUN: | FileCheck %s --check-prefixes=NO-PIE | ||
| ! RUN: %flang -target aarch64-windows-msvc -pie -### %s 2>&1 \ | ||
| ! RUN: | FileCheck %s --check-prefixes=NO-PIE,UNUSED | ||
| ! RUN: %flang -target aarch64-windows-msvc -no-pie -### %s 2>&1 \ | ||
| ! RUN: | FileCheck %s --check-prefixes=NO-PIE,UNUSED | ||
| ! | ||
| ! PIE: "-pie" | ||
| ! NO-PIE-NOT: "-pie" | ||
| ! UNUSED: warning: argument unused during compilation: '{{(-no)?}}-pie' | ||
| ! ------------------------------------------------------------------------------ | ||
|  | ||
| program hello | ||
| write(*,*), "Hello world!" | ||
| end program hello | ||
This file was deleted.
      
      Oops, something went wrong.
      
    
  
  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.