Opened 18 months ago

Closed 12 months ago

Last modified 12 months ago

#15112 closed bug (fixed)

ghc 8.4.2 on OS X: clang: warning: argument unused during compilation: '-nopie'

Reported by: elaforge Owned by:
Priority: highest Milestone: 8.6.1
Component: Compiler Version: 8.4.2
Keywords: Cc:
Operating System: MacOS X Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

% cat Nopie.hs
module Nopie where

main :: IO ()
main = putStrLn "hi"
% ghc -fforce-recomp -c -fhpc Nopie.hs
clang: warning: argument unused during compilation: '-nopie' [-Wunused-command-line-argument]
clang: warning: argument unused during compilation: '-nopie' [-Wunused-command-line-argument]

This happens for every source file when -fhpc is given, but also happens on links even when -fhpc isn't given. With -v, I see a call to gcc with -no-pie. When I run the same compile with ghc 8.4.1, I see the same call to gcc, only without that -no-pie flag, so this is new. It seems to be a harmless warning, but really clutters up the output.

Incidentally, it looks like the particular spelling of -no-pie was added to LLVM a year ago due to ghc: https://reviews.llvm.org/D35462 Not sure if that's relevant.

Change History (18)

comment:1 Changed 18 months ago by elaforge

Operating System: Unknown/MultipleMacOS X

comment:2 Changed 18 months ago by elaforge

Actually I see this with 8.4.1 too. This is probably related to the latest OS X update, not ghc version.

comment:3 Changed 18 months ago by bgamari

Yes, it sounds like it. Does this occur with a fresh installation of GHC?

comment:4 Changed 18 months ago by elaforge

By "fresh" do you mean HEAD? I haven't tried that yet. I do still see this when I run 8.4.2 as downloaded from https://www.haskell.org/ghc/download_ghc_8_4_2.html

comment:5 Changed 18 months ago by bgamari

Hmm, I'm a bit surprised that configure doesn't realize that -nopie isn't a valid flag. Do you have any insight into why this might be? config.log would be interesting to see.

comment:6 Changed 18 months ago by elaforge

I think it does, because I compiled from HEAD and I don't get the warning.

Of course the existing 8.4.2 binary was compiled before the latest OS X version, so it won't have that.

So maybe we just wait for this to go away in the next release?

comment:7 Changed 17 months ago by niteria

I couldn't build GHC HEAD with GHC 8.2.2 because of this error.

Modifying /usr/local/lib/ghc-8.2.2/settings to:

...
("C compiler supports -no-pie", "NO"),
...

worked it around for me.

Perhaps a reinstall works as well, I haven't tried.

comment:8 Changed 17 months ago by hvr

I investigated a bit, and for those wondering what is going on here, this is caused by a change in Apple's latest Xcode toolchain major version (which in fact has to do w/ the -no-pie alias being added as OP suspected)... as usual... and this retroactively affects all existing GHC releases which use the current autoconf test for the flag disabling PIE.

Last edited 17 months ago by hvr (previous) (diff)

comment:9 Changed 17 months ago by mcandre

Same error on my machine. I am working around this by using ghc 8.2 instead of ghc HEAD:

$ brew install ghc@8.2
$ brew link --force --overwrite ghc@8.2

Note: cabal-install should be installed beforehand, as it attempts to use ghc HEAD :/

Last edited 17 months ago by mcandre (previous) (diff)

comment:10 Changed 16 months ago by bgamari

Milestone: 8.6.18.8.1

These won't be addressed for GHC 8.6.

comment:11 Changed 15 months ago by goldfire

Milestone: 8.8.18.6.1
Priority: normalhighest

I'm going to bump the priority here.

I just downloaded the 8.4.3 (yes, I know, behind the times) binaries for my Mac and installed them with ./configure; make install. Now, every time I link an executable, I get

clang: warning: argument unused during compilation: '-nopie' [-Wunused-command-line-argument]

I downloaded straight from downloads.haskell.org/~ghc/8.4.3.

As comment:7 suggests, if I adjust the settings file, all is well. It seems easy enough to fix this, and we're giving a bad user experience without this fix.

If you disagree with my priority bump (either because, say, there's something unique about my setup which makes my experience atypical; or because this is actually hard to fix and shouldn't be a release blocker) feel free to reverse my actions.

comment:12 Changed 15 months ago by George

I can't reproduce in ghc alpha 8.6.1. I used to see this but I think it is fixed by the latest GHC or by MacOS 13.6 Here are the version details

 ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.6.0.20180714
bash-3.2$ gcc -v
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple LLVM version 9.1.0 (clang-902.0.39.2)
Target: x86_64-apple-darwin17.7.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

comment:13 Changed 14 months ago by bgamari

goldfire, have you seen this with 8.6?

comment:14 Changed 13 months ago by George

Status: newinfoneeded

comment:15 Changed 12 months ago by George

I can confirm I don't see it with 8.6.1 final

comment:16 Changed 12 months ago by bgamari

Resolution: fixed
Status: infoneededclosed

Thanks!

comment:17 Changed 12 months ago by bgamari

comment:18 Changed 12 months ago by bgamari

Unfortunately this fix didn't make it into 8.4.4. If you are experiencing this look at comment:7 for a workaround.

Note: See TracTickets for help on using tickets.