Skip to content
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

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

Merged
merged 4 commits into from Sep 13, 2023

Conversation

flavorjones
Copy link
Owner

@flavorjones flavorjones commented Sep 9, 2023

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 flavorjones force-pushed the 118-fedora-pkgconf branch 3 times, most recently from 2434045 to 9a51dfe Compare September 9, 2023 16:15
@flavorjones
Copy link
Owner Author

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 flavorjones force-pushed the 118-fedora-pkgconf branch 5 times, most recently from d7937bd to 74ac5a1 Compare September 10, 2023 15:49
flavorjones added a commit to sparklemotion/sqlite3-ruby that referenced this pull request Sep 10, 2023
flavorjones added a commit to sparklemotion/sqlite3-ruby that referenced this pull request Sep 10, 2023
flavorjones added a commit to sparklemotion/sqlite3-ruby that referenced this pull request Sep 10, 2023
@flavorjones
Copy link
Owner Author

Early feedback from sparklemotion/sqlite3-ruby#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 flavorjones force-pushed the 118-fedora-pkgconf branch 3 times, most recently from 667b7c8 to d5e0278 Compare September 10, 2023 22:53
flavorjones added a commit to sparklemotion/sqlite3-ruby that referenced this pull request Sep 10, 2023
flavorjones added a commit to sparklemotion/sqlite3-ruby that referenced this pull request Sep 10, 2023
flavorjones added a commit to sparklemotion/sqlite3-ruby that referenced this pull request Sep 11, 2023
@flavorjones flavorjones changed the title fix the fedora pkgconf library path issue support pkgconf for setting compiler and linker flags in an extconf Sep 11, 2023
flavorjones added a commit to sparklemotion/sqlite3-ruby that referenced this pull request Sep 11, 2023
@flavorjones flavorjones changed the title support pkgconf for setting compiler and linker flags in an extconf feat: MiniPortile.activate_mkmf which uses pkg-config files to configure compiler and linker flags Sep 11, 2023
flavorjones added a commit to sparklemotion/sqlite3-ruby that referenced this pull request Sep 11, 2023
@flavorjones flavorjones force-pushed the 118-fedora-pkgconf branch 3 times, most recently from 22e03ca to 045b7b9 Compare September 13, 2023 12:42
@flavorjones flavorjones changed the title feat: MiniPortile.activate_mkmf which uses pkg-config files to configure compiler and linker flags feat: MiniPortile.activate_mkmf which supports pkg-config files to configure compiler and linker flags Sep 13, 2023
@flavorjones flavorjones changed the title feat: MiniPortile.activate_mkmf which supports pkg-config files to configure compiler and linker flags feat: MiniPortile.mkmf_config which supports pkg-config files to configure compiler and linker flags Sep 13, 2023
also:

- extract public methods `native_path` and `posix_path`
- fix LDFLAGS path on windows to use native path separators
and a local pkgconf file. This should catch the issue with fedora's
pkgconf in #118.
which will set $LDFLAGS and $CFLAGS for the recipe, including a new
feature to support pkg-config files for the library.

This should allow gems with C extensions that use mini_portile to more
easily configure compiler and linker flags.
@flavorjones flavorjones changed the title feat: MiniPortile.mkmf_config which supports pkg-config files to configure compiler and linker flags feat: MiniPortile#mkmf_config which supports pkg-config files to configure compiler and linker flags Sep 13, 2023
@flavorjones
Copy link
Owner Author

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.

@flavorjones flavorjones merged commit 6ae2e70 into main Sep 13, 2023
31 checks passed
@flavorjones flavorjones deleted the 118-fedora-pkgconf branch September 13, 2023 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

explore alternatives to setting LIBRARY_PATH
1 participant