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

[SR-10559] libdispatch fails to build with _FORTIFY_SOURCE=2 #617

Open
swift-ci opened this issue Apr 26, 2019 · 3 comments
Open

[SR-10559] libdispatch fails to build with _FORTIFY_SOURCE=2 #617

swift-ci opened this issue Apr 26, 2019 · 3 comments

Comments

@swift-ci
Copy link

Previous ID SR-10559
Radar None
Original Reporter mroi (JIRA User)
Type Bug

Attachment: Download

Environment

Error is reproducible when building on Linux by adding -D_FORTIFY_SOURCE=2 to the CFLAGS.

Additional Detail from JIRA
Votes 0
Component/s libdispatch
Labels Bug
Assignee mroi (JIRA)
Priority Medium

md5: 7b08875efa899b1d63183c32fe0bd5d5

Issue Description:

The Nix Packages collection on Linux routinely builds with the fortify option (-D_FORTIFY_SOURCE=2). Currently, libdispatch fails to build with the following error:

/home/michael/swift/src/swift-corelibs-libdispatch/src/queue.c:47:2: error: ignoring return value of function declared with 'warn_unused_result' attribute [-Werror,-Wunused-result]
        _dispatch_client_assert_fail(
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/michael/swift/src/swift-corelibs-libdispatch/src/internal.h:1056:3: note: expanded from macro '_dispatch_client_assert_fail'
                asprintf(&_msg, "%s" fmt, DISPATCH_ASSERTION_FAILED_MESSAGE, \
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/nix/store/sr4253np2gz2bpha4gn8gqlmiw604155-glibc-2.27-dev/include/bits/stdio2.h:199:3: note: expanded from macro 'asprintf'
  __asprintf_chk (ptr, __USE_FORTIFY_LEVEL - 1, __VA_ARGS__)
  ^~~~~~~~~~~~~~  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/michael/swift/src/swift-corelibs-libdispatch/src/queue.c:56:2: error: ignoring return value of function declared with 'warn_unused_result' attribute [-Werror,-Wunused-result]
        _dispatch_client_assert_fail(
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/michael/swift/src/swift-corelibs-libdispatch/src/internal.h:1056:3: note: expanded from macro '_dispatch_client_assert_fail'
                asprintf(&_msg, "%s" fmt, DISPATCH_ASSERTION_FAILED_MESSAGE, \
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/nix/store/sr4253np2gz2bpha4gn8gqlmiw604155-glibc-2.27-dev/include/bits/stdio2.h:199:3: note: expanded from macro 'asprintf'
  __asprintf_chk (ptr, __USE_FORTIFY_LEVEL - 1, __VA_ARGS__)
  ^~~~~~~~~~~~~~  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 errors generated.

Since the fix is very easy, I was hoping it could be considered, even though _FORTIFY_SOURCE may not be the recommended way of building swift.

@belkadan
Copy link

Seems reasonable. ktopley-apple (JIRA User)?

@swift-ci
Copy link
Author

Comment by Kim Topley (JIRA)

Yes, that looks reasonable. Please create a PR.

@swift-ci
Copy link
Author

Comment by Michael Roitzsch (JIRA)

Please refer to PR #474

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants