Ticket #32 (closed Defect: fixed)

Opened 1 year ago

Last modified 1 year ago

apg++ can't create precompilled header.

Reported by: UnFleshed One Assigned to: taj
Priority: High Milestone:
Component: apbuild Version: 1.2.3
Severity: Major Keywords: precompiled header; apg++
Cc:

Description

apg++ tries to compile and link precompiled header, which is somehow different from what g++ itself does.

g++ header.h -D... -I...

generates header.h.gch

while

apg++ header.h -D... -I...

fails with

/usr/lib/gcc/i386-redhat-linux/3.4.6/../../../crt1.o: In function '_start':
(.text+0x18): undefined reference to 'main'
collect2: ld returned 1 exit status

Tried with gcc 3.4.6 and 4.1.1.

Attachments

apbuild.patch (2.2 kB) - added by UnFleshed One on 07/19/07 15:23:49.
Patch against Apbuild directory

Change History

06/20/07 19:57:19 changed by UnFleshed One

When run with APBUILD_DEBUG=1 it says "Situation: compile and link" and adds bunch of linker flags.

Seems like Apbuild::GCC::situation() needs to detect this case as "compile" or "other" somehow. I think "single file, header by extention or by -x switch" will cover most of the cases.

(I can barely read perl, so don't expect a patch :))

07/19/07 15:23:49 changed by UnFleshed One

  • attachment apbuild.patch added.

Patch against Apbuild directory

07/19/07 15:30:31 changed by UnFleshed One

  • priority changed from Medium to High.
  • severity changed from Normal to Major.

Ok, I attached the patch.

- Added "os" extention to the list of object extentions. It is used by SCons Qt4 integration I use (for objects made from generated code or something), so it might very well be custom one-off extention.

- Added "precompiled header" situation and its handling in apgcc. Triggered when there is only one file passed, and it is a header by extention. Works for me, but I'm not sure how general it is.

07/19/07 15:42:20 changed by UnFleshed One

- Almost forgot, QtCore/Gui/Network? libraries bumped to the end of library list. For some reason, --as-needed flag looses them. Without --as-needed it links fine, as well as with them at the end. (Qt was build with apbuild too)

08/14/07 13:11:12 changed by taj

  • status changed from new to closed.
  • resolution set to fixed.

Thank you for the patch! Sorry for the long delay in getting it applied. I applied the SCons and precompiled header stuff.

I didn't add the Qt library stuff yet as I'm not sure what's going on. I'll look into it and see what I can figure out. While your fix is probably the right one, I'd like to investigate it first because it might be another bug (either with us or Qt). Also, unless you have a reason (like multiple Qt apps in your package), it's probably best to statically link Qt 4 for now (since it's not very widely spread).

- Taj

08/14/07 13:51:44 changed by UnFleshed One

I have about a dozen of Qt apps, all installed at once, so statically linking is out of the question :).

Also I use commercial Qt (4.2.2), although it shouldn't be any different with GPLed one.

The better way to fix this (and other special cases of this sort) is to have a way to specify a list of libraries that will be bumped to the end if encountered, keeping the original ordering as in the list.

So that if the list is

"-lQtCore -lQtGui -lAnotherBrokenLib"

And on command line it sees

apg++ ... -lQtGui -lSomeLib -lQtCore -lSomeOtherLib ...

Then actual command will be

g++ ... -as-needed ... -lSomeLib -lSomeOtherLib -lQtCore -lQtGui ...

08/21/07 20:47:57 changed by taj

(I see I forgot to mention this when I closed the ticket: #32 was fixed in r2395)