Skip to content

Update strlcpy from musl to 1.2.0 - #10910

Merged
kripken merged 1 commit into
masterfrom
musl
Apr 14, 2020
Merged

kripken merged 1 commit into
masterfrom
musl

Conversation

@kripken

@kripken kripken commented Apr 14, 2020

Copy link
Copy Markdown
Member

Fixes a musl bug noted in #7279 (comment)

(we should do a general upgrade when someone has time for that)

@sbc100

sbc100 commented Apr 14, 2020

Copy link
Copy Markdown
Collaborator

I agree regarding a full upgrade.

Would be nice to make it semi-automatic somehow, or at least write a bunch of scripts to make it easier to update our copy of musl

@sbc100

sbc100 commented Apr 14, 2020

Copy link
Copy Markdown
Collaborator

Can you explain briefly how/why this fixes anything? I've not seen that attribute before.

@kripken

kripken commented Apr 14, 2020 •

Copy link
Copy Markdown
Member Author

My best understanding: The normal loop uses a char* to copy. The compiler knows that that type can alias anything. The optimized loop copies entire chunks at a time, but the larger type it uses (size_t) can't alias other things by default (would be UB), so the compiler can do type-based alias analysis and optimize incorrectly. With the attribute, it knows it can alias and therefore that all the loops are working on the same data.

@kripken
kripken merged commit 5d0ae5c into master Apr 14, 2020
@kripken
kripken deleted the musl branch April 14, 2020 19:27
kripken pushed a commit that referenced this pull request May 26, 2020
Copies these functions verbatim from musl v1.2.0. #10910 #7279
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.

2 participants