Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#31948 closed defect (fixed)

apple-gcc42: change behavior of the -isysroot option

Reported by: royliu@… Owned by: royliu@…
Priority: Normal Milestone:
Component: ports Version: 2.0.3
Keywords: haspatch Cc: jeremyhu (Jeremy Huddleston Sequoia)
Port: apple-gcc42

Description (last modified by royliu@…)

When attempting to compile a port like virtualbox with the MacPorts apple-gcc42 compiler, strange errors like this occur:

/Developer/SDKs/MacOSX10.6.sdk/usr/include/stdarg.h:4:25: error: stdarg.h: No such file or directory

After further investigation, this is because the -isysroot option is set. Recall that doing so will cause the search for the compiler's own headers to occur in directories like (in the case of Xcode's own llvm-gcc-4.2):

/Developer/SDKs/MacOSX10.6.sdk/Developer/usr/llvm-gcc-4.2/lib/gcc/i686-apple-darwin11/4.2.1/include

Since we installed a MacPorts-based compiler, it will search in

/Developer/SDKs/MacOSX10.6.sdk/Developer/opt/local/lib/apple-gcc42/gcc/i686-apple-darwin11/4.2.1/include

Such a directory clearly doesn't exist, and this causes the apple-gcc42 compiler to not find headers like stdarg.h. The attached patch prevents prepending of the SDK root to the compiler's own search paths. I believe that this is a reasonable "fix" to the problem because:

  1. MacPorts doesn't put a bunch of compiler-specific stuff into the SDK directories themselves.
  2. The patch is essentially saying "Regardless of the SDK, I want to use a common set of compiler headers".

Again, this is not a bug, but more of a change tailor-made for the way that MacPorts distributes packages.

Attachments (4)

patch-incpath.c.diff (483 bytes) - added by royliu@… 12 years ago.
A patch that prevents prepending of the -isysroot option argument to the compiler's own search path.
patch-isysroot.diff (2.7 KB) - added by royliu@… 12 years ago.
The cumulative patch for the port itself.
test.cpp (326 bytes) - added by royliu@… 12 years ago.
A small test case which should fail without the patch.
build_test.sh (312 bytes) - added by royliu@… 12 years ago.
A script to build the test case (revision 2).

Download all attachments as: .zip

Change History (16)

Changed 12 years ago by royliu@…

Attachment: patch-incpath.c.diff added

A patch that prevents prepending of the -isysroot option argument to the compiler's own search path.

comment:1 Changed 12 years ago by royliu@…

Description: modified (diff)

comment:2 Changed 12 years ago by royliu@…

Cc: jeremyhu@… added

comment:3 Changed 12 years ago by royliu@…

I've also attached a cumulative patch for the port itself in patch-isysroot.diff.

Changed 12 years ago by royliu@…

Attachment: patch-isysroot.diff added

The cumulative patch for the port itself.

comment:4 Changed 12 years ago by ryandesign (Ryan Carsten Schmidt)

Cc: jeremyhu@… removed
Owner: changed from macports-tickets@… to jeremyhu@…

I imagine the portfile revision also needs to be increased.

comment:5 Changed 12 years ago by royliu@…

By the way, if you deign to see the problem for yourself, try compiling test.cpp with build_test.sh without the patch. I've attached them.

Changed 12 years ago by royliu@…

Attachment: test.cpp added

A small test case which should fail without the patch.

comment:6 Changed 12 years ago by jeremyhu (Jeremy Huddleston Sequoia)

Yeah, this seems like the right approach to me. The compiler's bits don't belong in the SDK anyways, so even if this "worked" before, we'd be getting the wrong headers.

I give this my maintainer blessing, but I'm confused why you modified other_langs.patch

comment:7 Changed 12 years ago by jeremyhu (Jeremy Huddleston Sequoia)

Owner: changed from jeremyhu@… to royliu@…

Also, do we need to do this for the vanilla gcc ports as well?

Changed 12 years ago by royliu@…

Attachment: build_test.sh added

A script to build the test case (revision 2).

comment:8 in reply to:  7 Changed 12 years ago by royliu@…

Well, assuming the patch is reasonable, yes: All Apple-modified compiler ports require patching. If I'm not mistaken, that means:

  • apple-gcc40
  • apple-gcc42
  • clang-2.9
  • clang-3.0
  • clang-3.1

Vanilla GCC doesn't seem to be affected, as search path modifications aren't present. Since this is such a far-reaching change, and since I'm not a compiler person, I am seeking your blessings as well as those of other compiler maintainers. :)

Replying to jeremyhu@…:

Also, do we need to do this for the vanilla gcc ports as well?

comment:9 Changed 12 years ago by royliu@…

Resolution: fixed
Status: newclosed

jeremyhu,

FYI, those patch changes help the patches apply without warnings. I've committed r87123 and am closing this for now. Please open a new bug if this change causes trouble.

-Roy

comment:10 Changed 12 years ago by jmroot (Joshua Root)

Cc: jeremyhu@… added

comment:11 Changed 12 years ago by jeremyhu (Jeremy Huddleston Sequoia)

Nope, the change looks right to me. If anything crops up, we'll address it then, but I think this is "the right way" ... toolchain headers shouldn't be in the SDK anyways. Thanks for catching it.

comment:12 Changed 12 years ago by jeremyhu (Jeremy Huddleston Sequoia)

Regression: #34233

Note: See TracTickets for help on using tickets.