-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Header only libraries do not build on Mac OS X #61
Comments
Do you have a empty.c in tools/cpp ? |
Yes. This was run from head with only running compile.sh and modifying examples/cpp/BUILD.
|
The rules aren't quite compatible with the Mac tools - that's why we added On Wed, Mar 25, 2015 at 8:20 PM Trevor Gray notifications@github.com
|
To clarify - the Mac tools don't allow static libraries (and maybe this On Wed, Mar 25, 2015 at 8:30 PM Ulf Adams ulf@adams.info wrote:
|
I just introduced a wrapper around gcc for another bug (the library path one we discussed on monday), let just do another wrapper around otool for that. |
sorry I means around libtool |
Ulf, I let you handle this one when you are back. |
Is # libtool_wrapper.sh
set -eu
LIBTOOL="/usr/bin/libtool"
GCC="/usr/bin/gcc"
TOOLS_DIR="$PWD/tools/cpp"
# Ensure that we have an 'empty' .o
if [ ! -e $TOOLS_DIR/empty.o ]; then
${GCC} -o $TOOLS_DIR/empty.o -c $TOOLS_DIR/empty.cc
fi
# Call normal libtool with the addition empty .o
${LIBTOOL} "$@" $TOOLS_DIR/empty.o the worse thing ever to fix this or only the second-worst thing? |
Installed bazel on May 24, cloned from github. Mac OS X Yosemite, this issue is still present, even though there is an empty.cc on the bazel-project/tools/cpp/ dir. Any idea why? |
I've encountered the same issue while trying to build Boost on OS X with Xcode 6.4. In that case, adding an empty.cc (with linkstatic = 1 to silence warnings) does not help. |
I'm back now, and this seems like it's critical to fix. I've made some progress on a fix, which is going to be to remove the static / dynamic libraries if there aren't any object files. There's a chance that this breaks users who rely on the implicit output files <name>.a or <name>.so being available, but I don't expect that to be widely used. For those using the workaround, the empty.cc file needs to be actually referenced in cc_library.srcs (and you'll still get warnings from the linker). |
I will often wrap a genrule() built library (built, say, with autoconf) with a cc_library(); among other benefits, this allows me to specify the correct include paths for the library's headers and have them handled transitive-magically. If implicit output files are removed, will this trick still work? |
Yes, that's not a problem. I only know a single use case for the .a or .so implicit outputs, and there's a workaround for that. I also had a quick look through our internal code base, and there are few, if any, places that rely on the 'old' behavior. |
I'm running Mac OS X 10.10.3. It looks like libtool complains when trying to build header only libraries. Adding an empty cc file to the build rule fixes this, however a warning will be output and it does not feel very clean to have empty cc files littered all over the place.
Sample build rule and output below:
The text was updated successfully, but these errors were encountered: