build to fail with musl libc with: error: 'basename' was not declared in this scope
Categories
(Core :: Gecko Profiler, defect)
Tracking
()
Tracking | Status | |
---|---|---|
firefox75 | --- | fixed |
People
(Reporter: natanael.copa, Assigned: mforney)
Details
Attachments
(5 files)
1.40 KB,
patch
|
jseward
:
review+
|
Details | Diff | Splinter Review |
1.32 KB,
patch
|
Details | Diff | Splinter Review | |
784 bytes,
patch
|
Details | Diff | Splinter Review | |
774 bytes,
patch
|
mforney
:
review+
|
Details | Diff | Splinter Review |
47 bytes,
text/x-phabricator-request
|
Details | Review |
Reporter | ||
Comment 1•11 years ago
|
||
Reporter | ||
Comment 2•11 years ago
|
||
Reporter | ||
Comment 3•11 years ago
|
||
Reporter | ||
Comment 4•11 years ago
|
||
Comment 5•11 years ago
|
||
Comment 6•11 years ago
|
||
Reporter | ||
Comment 7•11 years ago
|
||
Comment 8•11 years ago
|
||
Comment 9•11 years ago
|
||
Comment 10•10 years ago
|
||
Updated•10 years ago
|
Comment 11•10 years ago
|
||
Comment 12•10 years ago
|
||
Comment 13•9 years ago
|
||
Comment 14•9 years ago
|
||
Comment 15•9 years ago
|
||
Comment 16•9 years ago
|
||
Comment 17•9 years ago
|
||
Updated•9 years ago
|
Comment 18•9 years ago
|
||
Comment 19•9 years ago
|
||
Comment 20•8 years ago
|
||
Comment 22•8 years ago
|
||
Comment 23•8 years ago
|
||
Comment 24•8 years ago
|
||
Reporter | ||
Comment 25•8 years ago
|
||
Comment 26•8 years ago
|
||
Reporter | ||
Comment 27•8 years ago
|
||
Comment 28•6 years ago
|
||
https://dxr.mozilla.org/mozilla-central/source/mozglue/baseprofiler/lul/LulElf.cpp#54
As you can see we are including libgen.h so there is no reason we should not include the header. These 2 profilers should be sync'd from what I understand.
Assignee | ||
Comment 29•5 years ago
|
||
I'd really like to see this issue fixed, especially since it has such an easy fix. Right now every musl-based Linux distribution has to patch around this.
I attached another alternative patch, which just uses std::string functions to get the exact same behavior as the current GNU basename version (since we are already working with a std::string here).
Assignee | ||
Comment 30•5 years ago
|
||
Currently, the GNU version of basename from string.h is used, which
has behavior that conflicts with the POSIX version in libgen.h.
The GNU basename is not available in all libcs. In particular, it
is missing in musl libc, causing a build failure:
error: 'basename' was not declared in this scope
The GNU version has the following implementation:
char *p = strrchr (filename, '/');
return p ? p + 1 : (char *) filename;
The POSIX version has slightly different semantics. It may modify
its argument string, or copy part of it to static storage. However,
it will also delete trailing slashes, while the GNU version will
return the empty string if there is a trailing slash.
This change resolves the issue by including libgen.h, adopting POSIX
basename semantics. This should be a safe change for the following
reasons:
-
The google-breakpad code, from which this code was derived, has
also switched to the POSIX basename:
https://chromium.googlesource.com/breakpad/breakpad/+/072f86ca83bb7138fe33f10b6380badd9ef7f065%5E%21/#F4 -
The version of LulElf.cpp in mozglue/baseprofiler has also switched
to the POSIX basename:
https://hg.mozilla.org/mozilla-central/annotate/de1c3ae8df14cdb2c94a817b02dcffcb2cee12e2/mozglue/baseprofiler/lul/LulElf.cpp#l54 -
The BaseFileName function is called only with paths to ELF files,
never directories, so the paths will never contain a trailing
slash, and the two versions of basename will behave identically.
Updated•5 years ago
|
Comment 31•5 years ago
|
||
(In reply to mforney from comment #30)
Created attachment 9123019 [details]
Bug 1041962 - Include libgen.h for basenameCurrently, the GNU version of basename from string.h is used, which
has behavior that conflicts with the POSIX version in libgen.h.The GNU basename is not available in all libcs. In particular, it
is missing in musl libc, causing a build failure:error: 'basename' was not declared in this scope
The GNU version has the following implementation:
char *p = strrchr (filename, '/');
return p ? p + 1 : (char *) filename;The POSIX version has slightly different semantics. It may modify
its argument string, or copy part of it to static storage. However,
it will also delete trailing slashes, while the GNU version will
return the empty string if there is a trailing slash.This change resolves the issue by including libgen.h, adopting POSIX
basename semantics. This should be a safe change for the following
reasons:
The google-breakpad code, from which this code was derived, has
also switched to the POSIX basename:
https://chromium.googlesource.com/breakpad/breakpad/+/072f86ca83bb7138fe33f10b6380badd9ef7f065%5E%21/#F4The version of LulElf.cpp in mozglue/baseprofiler has also switched
to the POSIX basename:
https://hg.mozilla.org/mozilla-central/annotate/de1c3ae8df14cdb2c94a817b02dcffcb2cee12e2/mozglue/baseprofiler/lul/LulElf.cpp#l54The BaseFileName function is called only with paths to ELF files,
never directories, so the paths will never contain a trailing
slash, and the two versions of basename will behave identically.
Are you serioues, your gonna jump on a bug copy a patch and take credit for something you did not write? I can officially say I have seen it all now.
Assignee | ||
Comment 32•5 years ago
|
||
Are you serioues, your gonna jump on a bug copy a patch and take credit for something you did not write? I can officially say I have seen it all now.
I am not trying to take credit for anything, I don't care about that at all. I'm trying to get this issue fixed. It is pretty clear that to fix an error 'basename' not declared in this scope
can be resolved by including the header that declares this function. By your logic, @gerald has also "stolen" Samuel's patch: https://hg.mozilla.org/mozilla-central/annotate/de1c3ae8df14cdb2c94a817b02dcffcb2cee12e2/mozglue/baseprofiler/lul/LulElf.cpp#l54
This issue has been open for 6 years, all the while patches have been available. It seems like the thing to do to move this forward is to submit the change for review through Mozilla's phabricator, as described in https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/How_to_Submit_a_Patch. Nobody has done this, so in the interest of getting this issue fixed, I have created D61047 after doing research about similar fixes for other files derived from the same code. If Samuel or anyone else who proposed a patch wants to propose their own patch for review, they are welcome to, and I will drop mine.
Assignee | ||
Comment 33•5 years ago
|
||
I believe I can amend my changeset to set the author to Samuel Holland, but I will have to check that he's okay with the commit message I have written.
Assignee | ||
Comment 34•5 years ago
|
||
(In reply to mforney from comment #33)
I believe I can amend my changeset to set the author to Samuel Holland, but I will have to check that he's okay with the commit message I have written.
This is now resolved.
Comment 35•5 years ago
|
||
I will try to resolve this in the week 3-7 Feb 2020. Unfortunately I have no
bandwidth to deal with it this coming week.
Comment 36•5 years ago
|
||
(In reply to mforney from comment #34)
I believe I can amend my changeset to set the author to Samuel Holland, but I will have to check that he's okay with the commit message I have written.
This is now resolved.
What is the resolution?
Assignee | ||
Comment 37•5 years ago
|
||
(In reply to Julian Seward [:jseward] from comment #36)
(In reply to mforney from comment #34)
I believe I can amend my changeset to set the author to Samuel Holland, but I will have to check that he's okay with the commit message I have written.
This is now resolved.
What is the resolution?
I contacted Samuel to see if he was okay with the commit message I wrote, and he said he was, so I amended the changeset in D61047 to list him as the author.
Comment 38•5 years ago
|
||
Comment 39•5 years ago
|
||
bugherder |
Updated•4 years ago
|
Updated•4 years ago
|
Description
•