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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this really addresses the root issue. The problem is that we're trying to look for
gmp.h
in a specific location, even thoughgmp.h
is already on the default include path. We should instead be checking whether the compiler sees thegmp.h
header, e.g. by usingAC_LINK_IFELSE
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we're using pkg-config for several other extensions as well, shouldn't we use it for ext/gmp too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GMP does not support pkg-config, unfortunately.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that it is better to let the compiler figure out if it can see the header. My autoconf-fu just wasn't strong enough to figure out how to do that right, but I'll take another look. Shouldn't it be AC_COMPILE_IFELSE though? If we're looking for header, linking is not necessary I think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe @petk also has ideas here on how to do this nicely.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the -print-multiarch seems to be the name of this directory, yes. How about then another
sed
? Unless thisunknown
is also output by PHP's scripts then the$host_vendor
might beunknown
.dnl comment here MACHINE_INCLUDES=$($CC -dumpmachine | $SED "s/-$host_vendor-/-/" | $SED 's/-unknown//')
Providing the
--host
option to be able to build with clang is from user point of view a bit hard to figure out. I would like to be able to build php using clang with only something like this:and let those m4 files figure out what other things are needed for clang specifics. (in ideal case scenario of course).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the mention, @petk. Always happy to be involved.
If you want to handle gcc and clang at the same time, you can simply do this:
That said, the detection code in
ext/gmp/config.m4
needs an overhaul.AC_CHECK_HEADERS
works well, but doesn't provide the path. I'm hoping there is a macro we can use for that, or even write one.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there are two different cases here: Manually specified GMP_DIR and use of system libgmp. If system libgmp is used, then both the include path and the lib path should already have the GMP headers / library and actually figuring out what the directories are shouldn't be necessary.
It might be easiest to just split these cases: If a path is specified, check for gmp.h as we do now. If it itsn't then use AC_LINK_IFELSE without any extra -I or -L to ensure both the library and header is found, and add the library without an additional libpath.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hughmcmaster clang add -unknown, not -pc, at least on Travis system. Maybe on some other system it adds -pc too. That's the problem - it's not predictable, really.
Maybe this is the best way, really.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is urgent, you can filter out the
-pc
or-unknown
part of the string with($CC -dumpmachine | cut -d '-' -f 1,3-)
.I've sent a patch to add pkg-config support to upstream gmp, but it's still going to take time for a new version to appear with this.