Skip to content

Implement building Linux-PAM using meson#824

Merged
ldv-alt merged 3 commits intomasterfrom
meson
Sep 11, 2024
Merged

Implement building Linux-PAM using meson#824
ldv-alt merged 3 commits intomasterfrom
meson

Conversation

@ldv-alt
Copy link
Member

@ldv-alt ldv-alt commented Sep 3, 2024

On my non-representative hardware, the full build using autotools
(./autogen.sh && CFLAGS=-O2 ./configure && make -j$(nproc) && make -j$(nproc) install)
takes about 45 seconds.

On the same hardware, the full build using meson
(meson setup -Doptimization=2 dir && meson compile -C dir && meson install -C dir)
takes just about 7.5 seconds.

@ldv-alt
Copy link
Member Author

ldv-alt commented Sep 3, 2024

@keszybz, could you have a look at this, please?

@thkukuk
Copy link
Contributor

thkukuk commented Sep 3, 2024

I really like this switch. But please, if we do the switch, remove the old configure script and Makefiles, maintaining two build systems is a nightmare.

@ldv-alt
Copy link
Member Author

ldv-alt commented Sep 3, 2024

I really like this switch. But please, if we do the switch, remove the old configure script and Makefiles, maintaining two build systems is a nightmare.

My initial plan was to make a release that still supports both build systems, but contains a deprecation warning, and remove autotools support right after the release. This would allow downstreams ample time to prepare for migration. Do you think this approach is overcautious and we should rather do the switch right away?

@thkukuk
Copy link
Contributor

thkukuk commented Sep 3, 2024

This would allow downstreams ample time to prepare for migration. Do you think this approach is overcautious and we should rather do the switch right away?

I don't really see a need to prepare migration, in the end all distributions should meanwhile have packages using meson, so it's just replacing configure & make with the corresponding meson files.
But I'm fine if we keep configure for one more release and remove it only afterwards.
May fear is that we end like util-linux: configure and meson with the big problem that they are never in sync and both have their own problems and bugs.

@ikerexxe
Copy link
Contributor

ikerexxe commented Sep 4, 2024

For what it's worth, as a Fedora maintainer I'm fine with just providing meson and changing the build system for a release. It's a big change that I think will pay off in the medium/long term.

@ldv-alt
Copy link
Member Author

ldv-alt commented Sep 4, 2024

Well, if nobody sees any benefits in keeping autotools support for the next release, I'm fine with dropping it before the release.

@thkukuk
Copy link
Contributor

thkukuk commented Sep 9, 2024

I'm trying to build our pam packages currently with meson and this PR. We build two packages: a very small one and a full features one.

I see the following error:

[   10s] Run-time dependency libsystemd found: NO (tried pkgconfig)
[   10s] 
[   10s] meson.build:307:13: ERROR: Dependency "libsystemd" not found, tried pkgconfig

I have to explicit disable logind. But that is defined as "auto", so shouldn't meson skip libsystemd dependency if it does not find it?
If I disable logind with "-Dlogind=disabled", it works.

Similar for pam_userdb:
meson.build:332:15: ERROR: C shared or static library 'db' not found
pam_userdb is "auto", but we get an error if the required libdb is not found. Disabling pam_userdb also solves this.
Same for "nis" and libnsl and "docs" and the dependencies.

It's irritating that you need to look at the meson.build script to find out which option you need to disable if you don't want a dependency.

Copy link

@keszybz keszybz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a lot of lines to review ;) I gave it a quick scan, and it looks all very nice. There probably are some minor things that'll need to be adjusted, but I think it's best to just merge this and use it.

I made some small suggestions. The only bigger issue I wonder about is whether it makes sense to symlink a shared meson.build file into multiple subdirectories. IIUC, this was done to allow the outputs to be produced in those subdirectories. If that is not necessary, I'd consider just using a single file. But maybe that's not feasible…

@keszybz
Copy link

keszybz commented Sep 9, 2024

BTW, I get this:

[34/362] Generating doc/specs/parse_y.[ch] with a custom command
../doc/specs/parse_y.y: warning: 2 shift/reduce conflicts [-Wconflicts-sr]
../doc/specs/parse_y.y: warning: 8 reduce/reduce conflicts [-Wconflicts-rr]
../doc/specs/parse_y.y: note: rerun with option '-Wcounterexamples' to generate conflict counterexamples
../doc/specs/parse_y.y:97.3-123.1: warning: rule useless in parser due to conflicts [-Wother]
   97 | | doc stuff RIGHT stuff RIGHT stuff NEWLINE {
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Maybe this is related to bison version? (I have bison-3.8.2-7.fc40.x86_64 here.)

@thkukuk
Copy link
Contributor

thkukuk commented Sep 9, 2024

There are missing options which we used with configure:

  • --htmldir
  • --pdfdir

@ldv-alt
Copy link
Member Author

ldv-alt commented Sep 9, 2024

I'm trying to build our pam packages currently with meson and this PR. We build two packages: a very small one and a full features one.

I see the following error:

[   10s] Run-time dependency libsystemd found: NO (tried pkgconfig)
[   10s] 
[   10s] meson.build:307:13: ERROR: Dependency "libsystemd" not found, tried pkgconfig

I have to explicit disable logind. But that is defined as "auto", so shouldn't meson skip libsystemd dependency if it does not find it? If I disable logind with "-Dlogind=disabled", it works.

I didn't expect this behavior. I definitely tested this, and I get the following instead without any errors:

Run-time dependency libsystemd found: NO (tried pkgconfig and cmake)

I expect that

option('logind', type: 'feature', value: 'auto',
       description: 'logind support in pam_issue and pam_timestamp')
...
libsystemd = dependency('libsystemd', version: '>= 254', required: get_option('logind'))

would make libsystemd dependency optional. I wonder why it doesn't work this way on your side.

This is meson 1.5.1.

@keszybz, any ideas why this check would behave so differently?

@ldv-alt
Copy link
Member Author

ldv-alt commented Sep 9, 2024

There are missing options which we used with configure:

* `--htmldir`

* `--pdfdir`

Indeed, these are provided by autoconf. Added.

@ldv-alt
Copy link
Member Author

ldv-alt commented Sep 9, 2024

I'm trying to build our pam packages currently with meson and this PR. We build two packages: a very small one and a full features one.
I see the following error:

[   10s] Run-time dependency libsystemd found: NO (tried pkgconfig)
[   10s] 
[   10s] meson.build:307:13: ERROR: Dependency "libsystemd" not found, tried pkgconfig

I have to explicit disable logind. But that is defined as "auto", so shouldn't meson skip libsystemd dependency if it does not find it? If I disable logind with "-Dlogind=disabled", it works.

I didn't expect this behavior. I definitely tested this, and I get the following instead without any errors:

Run-time dependency libsystemd found: NO (tried pkgconfig and cmake)

This (no libsystemd, no error) also happens in github CI.

@thkukuk
Copy link
Contributor

thkukuk commented Sep 10, 2024

The cc.find_library() calls are missing "required=false" as argument. From meson documentation:
If set true, Meson will abort with an error if the library could not be found. Otherwise, Meson will continue and the found method of the returned object will return false.
default = true
No idea why it works for you, it should not if cc.find_library() get's called according to the documentation. Adding "required=false" fixes it for me.

@ldv-alt
Copy link
Member Author

ldv-alt commented Sep 10, 2024

The cc.find_library() calls are missing "required=false" as argument.

Indeed, but this affects only the pam_userdb case. The use of crypt library doesn't seem to be optional because it's used unconditionally by pam_pwhistory, and other libraries are not looked up using cc.find_library().

@thkukuk
Copy link
Contributor

thkukuk commented Sep 10, 2024

Of course not all find_library() calls require "required: false" as argument. Some have it already (like 'util'), other don't need it, but the three ones in the userdb case are missing it.

@thkukuk
Copy link
Contributor

thkukuk commented Sep 10, 2024

This (no libsystemd, no error) also happens in github CI.

According to the meson documentation the libsystemd check is correct and should work. But I see the error on all systems with meson 1.3.1 and 1.5.1. Need to try to debug that later...

@thkukuk
Copy link
Contributor

thkukuk commented Sep 10, 2024

Between, I updated our PAM package with this PR and adjusted the spec file, this was really simple.
So for me, the current state is good enough to get merged.

On my non-representative hardware, the full build using autotools
(./autogen.sh && CFLAGS=-O2 ./configure && make -j`nproc` && make -j`nproc` install)
takes about 45 seconds.

On the same hardware, the full build using meson
(meson setup -Doptimization=2 dir && meson compile -C dir && meson install -C dir)
takes just about 7.5 seconds.
Mark a few files and directories with export-ignore attribute so that
they won't be added to archive files.
@thkukuk
Copy link
Contributor

thkukuk commented Sep 10, 2024

This (no libsystemd, no error) also happens in github CI.

According to the meson documentation the libsystemd check is correct and should work. But I see the error on all systems with meson 1.3.1 and 1.5.1. Need to try to debug that later...

Found it, ignore it. It's a "feature" of our build system.
So the PR is now fine with the pam_userdb find_library fixes.

@ldv-alt ldv-alt force-pushed the meson branch 3 times, most recently from 033ff2c to 26a5ac8 Compare September 10, 2024 22:22
@ldv-alt
Copy link
Member Author

ldv-alt commented Sep 11, 2024

The only remaining issue I'm aware of is what do we do with the make releasedocs concept.

The idea of distributing pre-built documentation became flawed when we started to use profile-docbook.xsl to generate parametrized manual pages.
Now, distributing anything pre-built wouldn't play well with the meson model of placing everything it builds into a separate build directory tree.

All that goes slightly beyond the scope of this PR, but should be decided upon before the final removal of autotools build support.

@ldv-alt
Copy link
Member Author

ldv-alt commented Oct 15, 2024

Well, if nobody sees any benefits in keeping autotools support for the next release, I'm fine with dropping it before the release.

OK, I've submitted a PR that drops autotools support for the next release: #839.

@ldv-alt ldv-alt deleted the meson branch October 23, 2024 10:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants