added preliminary freebsd support #16

Open
cathalo wants to merge 3 commits from cathalo/wbg:freebsd into master
First-time contributor

This project was not too hard to get working on freebsd. I say preliminary as I have only observed it working with a .png file, however I wanted to make a pr so I can start working on a freebsd port that would not need patches to upstream.

This project was not too hard to get working on freebsd. I say preliminary as I have only observed it working with a .png file, however I wanted to make a pr so I can start working on a freebsd port that would not need patches to upstream.
cathalo added 1 commit 2024-06-15 17:50:00 +00:00
sevz reviewed 2024-06-15 18:09:22 +00:00
meson.build Outdated
@ -12,3 +13,3 @@
add_project_arguments(
['-D_POSIX_C_SOURCE=200809L', '-D_GNU_SOURCE'] +
(is_freebsd ? [] : ['-D_POSIX_C_SOURCE=200809L', '-D_GNU_SOURCE'] ),
Contributor

Does it fail to build with these macros defined?

Does it fail to build with these macros defined?
Author
First-time contributor

Yeah both of them are problematic for the build. The freebsd headers seem to not define stuff like memfd_create with these set.

Yeah both of them are problematic for the build. The freebsd headers seem to not define stuff like `memfd_create` with these set.
Contributor

memfd_create is a linux extension. And it seems like it was added in FreeBSD 13. You can take inspiration from foot https://codeberg.org/dnkl/foot/src/branch/master/shm.c#L343-L365 and https://codeberg.org/dnkl/foot/src/branch/master/meson.build#L15-L17

memfd_create is a linux extension. And it seems like it was added in [FreeBSD 13][0]. You can take inspiration from foot https://codeberg.org/dnkl/foot/src/branch/master/shm.c#L343-L365 and https://codeberg.org/dnkl/foot/src/branch/master/meson.build#L15-L17 [0]: https://man.freebsd.org/cgi/man.cgi?memfd_create
Author
First-time contributor

memfd_create is a linux extension. And it seems like it was added in FreeBSD 13. You can take inspiration from foot https://codeberg.org/dnkl/foot/src/branch/master/shm.c#L343-L365 and https://codeberg.org/dnkl/foot/src/branch/master/meson.build#L15-L17

So that it supports older versions of freebsd ? I tryed to add back the flags, however using the same logic as foot MEMFD_CREATE is defined and the functions are not exported due to the flags. I think -D_POSIX_C_SOURCE=200809L flag is specifically the culprit: this is not in foot either.

I can change it to be the same as foot and specify -D_GNU_SOURCE=200809L without any condition for linux or freebsd

> memfd_create is a linux extension. And it seems like it was added in [FreeBSD 13][0]. You can take inspiration from foot https://codeberg.org/dnkl/foot/src/branch/master/shm.c#L343-L365 and https://codeberg.org/dnkl/foot/src/branch/master/meson.build#L15-L17 > > [0]: https://man.freebsd.org/cgi/man.cgi?memfd_create So that it supports older versions of freebsd ? I tryed to add back the flags, however using the same logic as foot `MEMFD_CREATE` is defined and the functions are not exported due to the flags. I think `-D_POSIX_C_SOURCE=200809L` flag is specifically the culprit: this is not in foot either. I can change it to be the same as foot and specify `-D_GNU_SOURCE=200809L` without any condition for linux or freebsd
Contributor

memfd_create is a linux extension. And it seems like it was added in FreeBSD 13. You can take inspiration from foot https://codeberg.org/dnkl/foot/src/branch/master/shm.c#L343-L365 and https://codeberg.org/dnkl/foot/src/branch/master/meson.build#L15-L17

So that it supports older versions of freebsd ? I tryed to add back the flags, however using the same logic as foot MEMFD_CREATE is defined and the functions are not exported due to the flags. I think -D_POSIX_C_SOURCE=200809L flag is specifically the culprit: this is not in foot either.

Yes?, tbh I don't know what dnkl prefers.

> > memfd_create is a linux extension. And it seems like it was added in [FreeBSD 13][0]. You can take inspiration from foot https://codeberg.org/dnkl/foot/src/branch/master/shm.c#L343-L365 and https://codeberg.org/dnkl/foot/src/branch/master/meson.build#L15-L17 > > > > [0]: https://man.freebsd.org/cgi/man.cgi?memfd_create > > So that it supports older versions of freebsd ? I tryed to add back the flags, however using the same logic as foot `MEMFD_CREATE` is defined and the functions are not exported due to the flags. I think `-D_POSIX_C_SOURCE=200809L` flag is specifically the culprit: this is not in foot either. > Yes?, tbh I don't know what dnkl prefers.
Owner

Just do whatever foot does. It makes maintenance easier.

As for whether we need/should support older versions, I don't really have an opinion. I don't mind supporting it, so it's really up to you.

Just do whatever foot does. It makes maintenance easier. As for whether we need/should support older versions, I don't really have an opinion. I don't mind supporting it, so it's really up to you.
meson.build Outdated
@ -88,0 +92,4 @@
if is_freebsd
add_project_arguments('-D__freebsd__=1', language: 'c')
else
add_project_arguments('-D__linux__=1', language: 'c')
Contributor

The preprocessor already defines __linux__ and __FreeBSD___ depending on the platform.

The preprocessor already defines `__linux__` and `__FreeBSD___` depending on the platform.
cathalo marked this conversation as resolved
meson.build Outdated
@ -150,3 +165,3 @@
image_format_sources,
wl_proto_src + wl_proto_headers, version,
dependencies: [pixman, png, jpg, jxl, jxl_threads, webp, svg, wayland_client, tllist],
dependencies: dependencies,
Contributor

You can use libepoll = dependency('epoll-shim', required: false) and add it here directly (like foot).

You can use `libepoll = dependency('epoll-shim', required: false)` and add it here directly (like foot).
Author
First-time contributor

ahh cool, I have never used meson before so thanks for fixing the smells !

ahh cool, I have never used meson before so thanks for fixing the smells !
cathalo marked this conversation as resolved
cathalo added 1 commit 2024-06-15 18:22:14 +00:00
cathalo added 1 commit 2024-06-15 19:32:47 +00:00
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u freebsd:cathalo-freebsd
git checkout cathalo-freebsd

Merge

Merge the changes and update on Forgejo.
git checkout master
git merge --no-ff cathalo-freebsd
git checkout master
git merge --ff-only cathalo-freebsd
git checkout cathalo-freebsd
git rebase master
git checkout master
git merge --no-ff cathalo-freebsd
git checkout master
git merge --squash cathalo-freebsd
git checkout master
git merge --ff-only cathalo-freebsd
git checkout master
git merge cathalo-freebsd
git push origin master
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: dnkl/wbg#16
No description provided.