* [FFmpeg-devel] [PATCH] configure: Enable -fno-common for Darwin targets, avoid linker warnings
@ 2025-04-29 7:49 Martin Storsjö
2025-05-02 13:39 ` Martin Storsjö
0 siblings, 1 reply; 4+ messages in thread
From: Martin Storsjö @ 2025-04-29 7:49 UTC (permalink / raw)
To: ffmpeg-devel
Since GCC 10 and llvm.org Clang 11, -fno-common is the default.
However Apple's Xcode Clang hasn't followed suit yet, and still
defaults to -fcommon.
Compiling with -fcommon causes uninitialized global variables to
be treated as "common" (which allows multiple object files to have
similar definitions).
Common variables seem to have the issue that their intended alignment
isn't signaled, so the linker assumes that they may need alignment
according to their full size.
With large global tables, this can lead to linker warnings like
this, with Xcode 16.3:
ld: warning: reducing alignment of section __DATA,__common from 0x8000 to 0x4000 because it exceeds segment maximum alignment
This can be reproduced with a small snippet like this:
char table[16385];
int main(int argc, char* argv[]) { return 0; }
Compiling with -fno-common avoids this issue and warning, and
matches the default behaviour of other compilers. (Compiling with
-fno-common also avoids the risk of accidentally accepting
duplicate definitions of global variables, as long as they are
uninitialized.)
---
configure | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/configure b/configure
index ee270b770c..45c99239a8 100755
--- a/configure
+++ b/configure
@@ -5846,6 +5846,13 @@ case $target_os in
clang_version=$($cc -dumpversion)
test ${clang_version%%.*} -eq 11 && add_cflags -fno-stack-check
fi
+
+ # Xcode Clang doesn't default to -fno-common while upstream llvm.org
+ # Clang (and GCC) do. This avoids linker warnings on Xcode 16.3 about
+ # "reducing alignment of section __DATA,__common from 0x8000 to 0x4000
+ # because it exceeds segment maximum alignment".
+ check_cflags -fno-common
+
;;
msys*)
die "Native MSYS builds are discouraged, please use the MINGW environment."
--
2.39.5 (Apple Git-154)
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [FFmpeg-devel] [PATCH] configure: Enable -fno-common for Darwin targets, avoid linker warnings
2025-04-29 7:49 [FFmpeg-devel] [PATCH] configure: Enable -fno-common for Darwin targets, avoid linker warnings Martin Storsjö
@ 2025-05-02 13:39 ` Martin Storsjö
2025-05-05 8:45 ` Martin Storsjö
0 siblings, 1 reply; 4+ messages in thread
From: Martin Storsjö @ 2025-05-02 13:39 UTC (permalink / raw)
To: ffmpeg-devel
On Tue, 29 Apr 2025, Martin Storsjö wrote:
> Since GCC 10 and llvm.org Clang 11, -fno-common is the default.
> However Apple's Xcode Clang hasn't followed suit yet, and still
> defaults to -fcommon.
>
> Compiling with -fcommon causes uninitialized global variables to
> be treated as "common" (which allows multiple object files to have
> similar definitions).
>
> Common variables seem to have the issue that their intended alignment
> isn't signaled, so the linker assumes that they may need alignment
> according to their full size.
>
> With large global tables, this can lead to linker warnings like
> this, with Xcode 16.3:
>
> ld: warning: reducing alignment of section __DATA,__common from 0x8000 to 0x4000 because it exceeds segment maximum alignment
>
> This can be reproduced with a small snippet like this:
>
> char table[16385];
> int main(int argc, char* argv[]) { return 0; }
>
> Compiling with -fno-common avoids this issue and warning, and
> matches the default behaviour of other compilers. (Compiling with
> -fno-common also avoids the risk of accidentally accepting
> duplicate definitions of global variables, as long as they are
> uninitialized.)
> ---
> configure | 7 +++++++
> 1 file changed, 7 insertions(+)
Will push soon.
// Martin
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [FFmpeg-devel] [PATCH] configure: Enable -fno-common for Darwin targets, avoid linker warnings
2025-05-02 13:39 ` Martin Storsjö
@ 2025-05-05 8:45 ` Martin Storsjö
2025-05-05 11:10 ` Marvin Scholz
0 siblings, 1 reply; 4+ messages in thread
From: Martin Storsjö @ 2025-05-05 8:45 UTC (permalink / raw)
To: ffmpeg-devel
On Fri, 2 May 2025, Martin Storsjö wrote:
> On Tue, 29 Apr 2025, Martin Storsjö wrote:
>
>> Since GCC 10 and llvm.org Clang 11, -fno-common is the default.
>> However Apple's Xcode Clang hasn't followed suit yet, and still
>> defaults to -fcommon.
>>
>> Compiling with -fcommon causes uninitialized global variables to
>> be treated as "common" (which allows multiple object files to have
>> similar definitions).
>>
>> Common variables seem to have the issue that their intended alignment
>> isn't signaled, so the linker assumes that they may need alignment
>> according to their full size.
>>
>> With large global tables, this can lead to linker warnings like
>> this, with Xcode 16.3:
>>
>> ld: warning: reducing alignment of section __DATA,__common from 0x8000
>> to 0x4000 because it exceeds segment maximum alignment
>>
>> This can be reproduced with a small snippet like this:
>>
>> char table[16385];
>> int main(int argc, char* argv[]) { return 0; }
>>
>> Compiling with -fno-common avoids this issue and warning, and
>> matches the default behaviour of other compilers. (Compiling with
>> -fno-common also avoids the risk of accidentally accepting
>> duplicate definitions of global variables, as long as they are
>> uninitialized.)
>> ---
>> configure | 7 +++++++
>> 1 file changed, 7 insertions(+)
>
> Will push soon.
Pushed. I'll go ahead and backport this to a couple release branches as
well.
// Martin
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [FFmpeg-devel] [PATCH] configure: Enable -fno-common for Darwin targets, avoid linker warnings
2025-05-05 8:45 ` Martin Storsjö
@ 2025-05-05 11:10 ` Marvin Scholz
0 siblings, 0 replies; 4+ messages in thread
From: Marvin Scholz @ 2025-05-05 11:10 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On 5 May 2025, at 10:45, Martin Storsjö wrote:
> On Fri, 2 May 2025, Martin Storsjö wrote:
>
>> On Tue, 29 Apr 2025, Martin Storsjö wrote:
>>
>>> Since GCC 10 and llvm.org Clang 11, -fno-common is the default.
>>> However Apple's Xcode Clang hasn't followed suit yet, and still
>>> defaults to -fcommon.
>>>
>>> Compiling with -fcommon causes uninitialized global variables to
>>> be treated as "common" (which allows multiple object files to have
>>> similar definitions).
>>>
>>> Common variables seem to have the issue that their intended alignment
>>> isn't signaled, so the linker assumes that they may need alignment
>>> according to their full size.
>>>
>>> With large global tables, this can lead to linker warnings like
>>> this, with Xcode 16.3:
>>>
>>> ld: warning: reducing alignment of section __DATA,__common from 0x8000 to 0x4000 because it exceeds segment maximum alignment
>>>
>>> This can be reproduced with a small snippet like this:
>>>
>>> char table[16385];
>>> int main(int argc, char* argv[]) { return 0; }
>>>
>>> Compiling with -fno-common avoids this issue and warning, and
>>> matches the default behaviour of other compilers. (Compiling with
>>> -fno-common also avoids the risk of accidentally accepting
>>> duplicate definitions of global variables, as long as they are
>>> uninitialized.)
>>> ---
>>> configure | 7 +++++++
>>> 1 file changed, 7 insertions(+)
>>
>> Will push soon.
>
> Pushed. I'll go ahead and backport this to a couple release branches as well.
Good idea, thanks for the warning fix.
>
> // Martin
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-05-05 11:10 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-29 7:49 [FFmpeg-devel] [PATCH] configure: Enable -fno-common for Darwin targets, avoid linker warnings Martin Storsjö
2025-05-02 13:39 ` Martin Storsjö
2025-05-05 8:45 ` Martin Storsjö
2025-05-05 11:10 ` Marvin Scholz
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git