flavorjones / mini_portile

mini_portile and mini_portile2 - Simple autoconf and cmake builder for developers
MIT License
114 stars 51 forks source link

feat: `MiniPortile#mkmf_config` which supports pkg-config files to configure compiler and linker flags #131

Closed flavorjones closed 1 year ago

flavorjones commented 1 year ago

Closes #118

Currently, each C extension is responsible for figuring out the compiler and linker flags; and even using pkg-config is fraught because of lack of features or bugs in older Rubies and OS platforms.

The approach taken here is for a new method, MiniPortile#mkmf_config, to support reading a pkg-config file and set $LDFLAGS and $CFLAGS appropriately, doing all the hacky things that require specialized knowledge but that I don't want gem authors to have to learn how to do.

This should mean we don't need to use the pkgconf trick in extconf.rb anymore, which completely avoids the behavior of Fedora's pkgconf described in #118.

flavorjones commented 1 year ago

Boom, got the failure we wanted: https://github.com/flavorjones/mini_portile/actions/runs/6132073726/job/16642608209?pr=131#step:7:1788

assertion failed: LDFLAGS not updated correctly:
-L. -Wl,-z,relro -Wl,--as-needed  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed 
should have included '-L/__w/mini_portile/mini_portile/examples/ports/x86_64-redhat-linux/yaml/0.2.5/lib'
flavorjones commented 1 year ago

Early feedback from https://github.com/sparklemotion/sqlite3-ruby/pull/405 indicates that this approach isn't sufficient to replace using pkg-config. sqlite has static libs that must be on the link line; another example is libxml2 which has a non-standard include directory.

So what I'm going to try next is to take all the hacks around pkg-config and put them into mini_portile.

flavorjones commented 1 year ago

OK, this version is green (locally) for sqlite3-ruby, rcee, and nokogiri, so I'm going to merge it and ship a prerelease so I can kick the tires more thoroughly.