Opened 15 years ago

Closed 15 years ago

Last modified 48 years ago

#113 closed bug (Invalid)

package cc and ld opts inconsistent

Reported by: as49 Owned by: simonmar
Priority: normal Milestone:
Component: Driver Version: 5.04.2
Keywords: Cc:
Operating System: Architecture:
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


I try to create a package which passes
"--subsystem windows"
to the linker. As far as I understand it should be ok to have
extra_ld_opts = ["--subsystem windows"]
or, as ghc itself does it
extra_ld_opts = ["--subsystem", "windows"]
in the package description. However these flags are not 
given to the linker. I tried
extra_cc_opts = ["-Wl,--subsystem", "-Wl,windows"]
but these flags are not passed to the C compiler either.
I finally succeeded with
extra_ld_opts = ["-Wl,--subsystem", "-Wl,windows"]
which I suspect fails when compiling with the native code 

I am using the MSI of ghc 5.04.2.


Change History (5)

comment:1 Changed 15 years ago by simonmar

Logged In: YES 

The "linker" is in fact gcc, so when you add options to 
extra_ld_opts they are passed on the gcc command line.  If 
you want to actually pass options to ld, then you need to use 
the -Wl, prefix as you mentioned.

I don't understand your comments about extra_cc_opts - as 
far as I can tell these are always passed to C compilations.  
Could you give a specific example?

comment:2 Changed 15 years ago by as49

Logged In: YES 

I thought the linker is the linker and not the C compiler. With 
this in mind I would have expected that

extra_ld_opts = ["--subsystem", "windows"] 

winds up as -Wl,--subsystem -Wl,windows on the gcc 
command line. Similarly, I expected

extra_cc_opts = ["-Wl,--subsystem", "-Wl,windows"]

to end up on the command line of gcc. Where do these flags 
go to?

Furthermore, how am I to specify linker options if compilation 
is not via C?

I find the behaviour just very confusing.

comment:3 Changed 15 years ago by simonmar

Logged In: YES 

extra_cc_opts gets passed to gcc when doing C 
compilations (either Haskell compilations via C, or 
compilation of plain C files).

extra_ld_opts gets passed to gcc when doing linking.

You can use -v to see what options are being passed to 
which commands.

What exactly is wrong?

comment:4 Changed 15 years ago by as49

Logged In: YES 

Ok, so it's just a misunderstanding on my side.

I use ghc --make to build programs with my package so the 
whole build is just one invocation. I then assumed that 
extra_hc_flags are added to ghc's command line, 
extra_cc_flags are passed to gcc's command line and 
extra_ld_flags are passed to ld's command line. The latter 
doesn't hold because you invoke gcc to link. When I compiled 
with -v I got confused: I saw gcc when it linked the code, so I 
assumed extra_cc_flags is the place to alter this command line.

Sorry about the hassle,

comment:5 Changed 15 years ago by simonmar

Status: assignedclosed
Note: See TracTickets for help on using tickets.