commonmark / cmark

CommonMark parsing and rendering library and program in C
Other
1.63k stars 544 forks source link

macOS: pkgconfig contains wrong libdir #236

Closed ole closed 6 years ago

ole commented 6 years ago

Is this the right place to report issues with the cmark formula for Homebrew? If not, my apologies. Could somebody direct me to the proper place? Thanks!

I installed cmark 0.28.0 on macOS 10.13 High Sierra (build 17A362a, i.e. the GM; the final release has build number 17A365, but I hope that's not relevant to this issue):

> brew --version
Homebrew 1.3.4
Homebrew/homebrew-core (git revision 7bce0; last commit 2017-10-08)

> brew doctor
Your system is ready to brew.

> brew install cmark
==> Downloading https://homebrew.bintray.com/bottles/cmark-0.28.0.high_sierra.bottle.tar.gz
Already downloaded: /Users/elo/Library/Caches/Homebrew/cmark-0.28.0.high_sierra.bottle.tar.gz
==> Pouring cmark-0.28.0.high_sierra.bottle.tar.gz
🍺  /usr/local/Cellar/cmark/0.28.0: 17 files, 747.8KB

This is the pkgconfig file that I get:

> cat /usr/local/Cellar/cmark/0.28.0/lib/pkgconfig/libcmark.pc
prefix=/usr/local/Cellar/cmark/0.28.0
exec_prefix=/usr/local/Cellar/cmark/0.28.0
libdir=/usr/local/Cellar/cmark/0.28.0/
includedir=/usr/local/Cellar/cmark/0.28.0/include

Name: libcmark
Description: CommonMark parsing, rendering, and manipulation
Version: 0.28.0
Libs: -L${libdir} -lcmark
Cflags: -I${includedir}

If I'm not mistaken, libdir is wrong; it should be /usr/local/Cellar/cmark/0.28.0/lib, i.e. it's missing the final lib subdirectory.

As a result, pkgconfig returns the wrong thing for -L (libcmark.dylib is at cmark/0.28.0/lib, not cmark/0.28.0):

> pkg-config libcmark --libs --cflags
-I/usr/local/Cellar/cmark/0.28.0/include -L/usr/local/Cellar/cmark/0.28.0/ -lcmark

I don't think this issue is specific to macOS High Sierra. I downloaded the bottles for the older OSes manually (Sierra, El Capitan, Yosemite), and their libcmark.pc files look the same.

Building from source doesn't fix the issue, either:

> brew uninstall cmark
Uninstalling /usr/local/Cellar/cmark/0.28.0... (17 files, 747.8KB)

> brew install --build-from-source cmark
...
==> Installing cmark
==> Downloading https://github.com/jgm/cmark/archive/0.28.0.tar.gz
Already downloaded: /Users/elo/Library/Caches/Homebrew/cmark-0.28.0.tar.gz
==> cmake .. -DCMAKE_C_FLAGS_RELEASE=-DNDEBUG -DCMAKE_CXX_FLAGS_RELEASE=-DNDEBUG -DCMAKE_INSTALL_PREFIX
==> make
==> make test
==> make install
🍺  /usr/local/Cellar/cmark/0.28.0: 17 files, 748.5KB, built in 17 seconds

> cat /usr/local/Cellar/cmark/0.28.0/lib/pkgconfig/libcmark.pc
prefix=/usr/local/Cellar/cmark/0.28.0
exec_prefix=/usr/local/Cellar/cmark/0.28.0
libdir=/usr/local/Cellar/cmark/0.28.0/
includedir=/usr/local/Cellar/cmark/0.28.0/include

Name: libcmark
Description: CommonMark parsing, rendering, and manipulation
Version: 0.28.0
Libs: -L${libdir} -lcmark
Cflags: -I${includedir}
jgm commented 6 years ago

This isn't the right place. You might try https://github.com/Homebrew/brew and see if it says there how to report such bugs.

ole commented 6 years ago

@jgm Well, Homebrew says the right place is to "open an issue on the formula's repository", which is what led me here.

Having said that, I don't think anymore that this is a Homebrew issue (I'm going to edit the title of this issue accordingly).

I just built cmark from source and I'm seeing the same problem:

> cmake --version
cmake version 3.9.4

CMake suite maintained and supported by Kitware (kitware.com/cmake).

> git clone git@github.com:commonmark/cmark.git

Edit: I omitted the next two commands I typed when I first posted this:

> cd cmark
> make

Continuing with the results of make:

mkdir -p build; \
    cd build; \
    cmake .. \
        -G "Unix Makefiles" \
        -DCMAKE_BUILD_TYPE= \
        -DCMAKE_INSTALL_PREFIX=/usr/local \
        -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
-- The C compiler identification is AppleClang 9.0.0.9000037
-- The CXX compiler identification is AppleClang 9.0.0.9000037
...
[100%] Built target libcmark_static
Binaries can be found in build/src

> cat build/src/libcmark.pc
prefix=/usr/local
exec_prefix=/usr/local
libdir=/usr/local/
includedir=/usr/local/include

Name: libcmark
Description: CommonMark parsing, rendering, and manipulation
Version: 0.28.0
Libs: -L${libdir} -lcmark
Cflags: -I${includedir}

Again, libdir in the pkgconfig file is /usr/local/ where I'd expect /usr/local/lib. I admit I don't know a lot about pkgconfig, but that's wrong, isn't it?

jgm commented 6 years ago

+++ Ole Begemann [Oct 08 17 10:36 ]:

[1]@jgm Well, [2]Homebrew says the right place is to "open an issue on the formula's repository", which is what led me here.

I think they mean the homebrew formula for cmark, not the cmark upstream repository. I don't know where the homebrew formula for cmark is maintained, but that's what you need to look for.

I just built cmark from source and I'm seeing the same problem:

cmake --version cmake version 3.9.4

CMake suite maintained and supported by Kitware (kitware.com/cmake).

git clone git@github.com:commonmark/cmark.git mkdir -p build; \ cd build; \ cmake .. \ -G "Unix Makefiles" \ -DCMAKE_BUILD_TYPE= \ -DCMAKE_INSTALL_PREFIX=/usr/local \ -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -- The C compiler identification is AppleClang 9.0.0.9000037 -- The CXX compiler identification is AppleClang 9.0.0.9000037 ... [100%] Built target libcmark_static Binaries can be found in build/src

cat build/src/libcmark.pc prefix=/usr/local exec_prefix=/usr/local libdir=/usr/local/ includedir=/usr/local/include

Strange. Here's what I see when I build from source on OSX with default options:

prefix=/usr/local exec_prefix=/usr/local libdir=/usr/local/lib includedir=/usr/local/include

Maybe it has something to do with the custom CMAKE options you're passing in?

ole commented 6 years ago

First of all, I made a copy-and-paste mistake above (apologies!) that may have made it seem like I passed some custom CMake options, but if I did I'm not aware of it. I just called make (now corrected in my post above).

I don't know anything about CMake, so it's hard for me to debug this, but it seems pretty clear that for whatever reason, @CMAKE_INSTALL_LIBDIR@ (used in libcmark.pc.in) is blank on my machine.

The hardcoded lib directory was replaced by @CMAKE_INSTALL_LIBDIR@ in #185.

I have no idea why this would be the case or what I may have done to misconfigure my system. As far as I know I'm using a stock CMake (v 3.9.4), installed via Homebrew.

The fact that the prebuilt binaries distributed by Homebrew (whoever maintains them) seem to have the same issue at least suggests I'm not alone.

ole commented 6 years ago

Don't know if this helps, but my build/CMakeCache.txt file does list the value of CMAKE_INSTALL_LIBDIR as lib:

> cat build/CMakeCache.txt | grep -n -C 1 CMAKE_INSTALL_LIBDIR
110-//Object code libraries (lib)
111:CMAKE_INSTALL_LIBDIR:PATH=lib
112-
--
--
363-CMAKE_INSTALL_INFODIR-ADVANCED:INTERNAL=1
364://ADVANCED property for variable: CMAKE_INSTALL_LIBDIR
365:CMAKE_INSTALL_LIBDIR-ADVANCED:INTERNAL=1
366-//ADVANCED property for variable: CMAKE_INSTALL_LIBEXECDIR
jgm commented 6 years ago

Sorry! I wasn't using the latest code. I can now see the same behavior on my machine, now that I've pulled in that patch.

Let's check with the author of that patch about how CMAKE_INSTALL_LIBDIR is supposed to be set. I had assumed that it would be set automatically to lib by default...

jgm commented 6 years ago

OK, this is weird. If I just do 'touch src/libcmark.pc.in' and then 'make' again, I get the right path in build/src/libcmark.pc.

ole commented 6 years ago

@jgm Thanks!

nwellnhof commented 6 years ago

CMAKE_INSTALL_LIBDIR being blank is probably caused by https://github.com/commonmark/cmark/pull/240