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

musl libc compatibility #393

Merged
merged 5 commits into from
Dec 22, 2015
Merged

Conversation

robotanarchy
Copy link
Contributor

I'm packaging sway for Void Linux currently (trying out that distro).

sway currently uses two non-standard features, which I have fixed with this PR:

I've tested these commits on Void Linux with musl (I'll release my templates for this soon) and on Arch Linux (glibc of course).

Being more standard conform will not only allow musl libc users to use sway, but also users of other libc libraries and other exotic systems 👍

Linking fails otherwise:

Linking C executable ../bin/sway
/usr/bin/ld: CMakeFiles/sway.dir/commands.c.o: relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a shared object; recompile with -fPIC
CMakeFiles/sway.dir/commands.c.o: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
sway/CMakeFiles/sway.dir/build.make:442: recipe for target 'bin/sway' failed
works on arch (glibc) and void linux (tested with musl libc) now
I've tried to make as few changes, as possible.

Usually the reason for using qsort_r is, that you can pass an extra userdata pointer to the
compare function. However, in sway list_sort wrapped qsort_r and always called a wrapper
function for comparing, the wrapper function then had the real compare function as argument.
The only thing, that the wrapper function does, is dereferencing the 'left' and 'right' function
arguments before passing them to the real compare function.

I have renamed list_sort to list_qsort to avoid confusion (so nobody tries to use list_qsort like
list_sort) and removed the wrapper functionality. Now the dereferencing must be done in the
compare function, that gets passed.

Some compare functions were used in both list_sort and list_seq_find. To make the difference
clear, I've added a '_qsort' suffix to the compare functions, that are intended to be used with
the new list_qsort. (In other words: list_qsort is not compatible anymore with list_seq_find).

- Changed and renamed function (it isn't used anywhere but in commands.c, and only for sorting):
	compare_set -> compare_set_qsort
- New wrapper functions:
	sway_binding_cmp_qsort (for sway_binding_cmp)
	sway_mouse_binding_cmp_qsort (for sway_mouse_binding_cmp)
ddevault added a commit that referenced this pull request Dec 22, 2015
@ddevault ddevault merged commit 91c102a into swaywm:master Dec 22, 2015
@ddevault
Copy link
Contributor

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

CMake: Use FindBacktrace instead of hardcoding execinfo.h
2 participants