From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <ffmpeg-devel-bounces@ffmpeg.org>
Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100])
	by master.gitmailbox.com (Postfix) with ESMTPS id E89E949B8F
	for <ffmpegdev@gitmailbox.com>; Tue, 29 Apr 2025 07:49:27 +0000 (UTC)
Received: from [127.0.1.1] (localhost [127.0.0.1])
	by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 17149689D0A;
	Tue, 29 Apr 2025 10:49:22 +0300 (EEST)
Received: from mail-lf1-f52.google.com (mail-lf1-f52.google.com
 [209.85.167.52])
 by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 16DF8687C70
 for <ffmpeg-devel@ffmpeg.org>; Tue, 29 Apr 2025 10:49:15 +0300 (EEST)
Received: by mail-lf1-f52.google.com with SMTP id
 2adb3069b0e04-54e7967cf67so6006043e87.0
 for <ffmpeg-devel@ffmpeg.org>; Tue, 29 Apr 2025 00:49:15 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=martin-st.20230601.gappssmtp.com; s=20230601; t=1745912954; x=1746517754;
 darn=ffmpeg.org; 
 h=content-transfer-encoding:mime-version:message-id:date:subject:to
 :from:from:to:cc:subject:date:message-id:reply-to;
 bh=pxL6CyJLFqARuyxm78A0y2Ol9f5ADtY1xLs7C3866Gk=;
 b=beF+ttLDuheCBrJpB5ZKtXDcuKHE762ximHJOTPbZr1swzfZc0+uRdrkLFmtfcQrhU
 2zWuAn0eYl7Y53AgC0lxv1bvCG3fFN10Q0+wvWv+1WICnCfw1QhDI9T0s9iHvtd0TNAF
 3tVKTzFXAgC2s9aBkmgqNM+8Bzyj4IXLWUSvL4F7y9hCT0jwMCitsMxhqd+WpI4bO55r
 uAg7ribvYLV6h/mDDA1mWCQX1KZZX09UCXPxMEL+7YtnFPbkafsdVAtem3boiVSLroJ2
 iUHYVuoUUU0QnAnv8xpC87j5ftCK4QPJoYmKQv3BceLfuHGloTf2CxhcEolwLeP+vyhP
 2+BA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1745912954; x=1746517754;
 h=content-transfer-encoding:mime-version:message-id:date:subject:to
 :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
 bh=pxL6CyJLFqARuyxm78A0y2Ol9f5ADtY1xLs7C3866Gk=;
 b=TU9aEcKGMDGiBfF9IMCMGF02uX11mNJEXfqtPKSP6v+gG4SqN0MIsqtkj6lCFOiQKo
 ozxmFd713DMGy3RVZ2fUTL9FYvz1/UH7zUHLJtLU3ppaVV4rXf9l/ehd4PlAOwH7Hpzd
 +9p9AT3Wa16+TOqy+oUXELofAgy3k7dZb6dji/690jGsPwhT/FlrRjTP2i6IhOyho3pD
 aqs6aot2dnx9G8m2tTjIOdWd4iIyRybH3X+Mjsh+YwDNVXpFZaGITAmhNqyx5hxUVFEy
 2p0XocxuFr1tVyY1zaci4iBFinDZppCf7bV6ovWUWWmEDSLj8ezk/sKNkuAfcxfpfsoF
 RcmQ==
X-Gm-Message-State: AOJu0YwPSETck8tA/DRKNP+slbhh8I57wGl2EWlIQ1hxjm4Jf2R5jQZW
 52y9yPZOH41lFzwEozLMSma+sCwMFjFmGoDmdR/CMiV0RyYrFmJ+IUwRyYeXYxdnKzvyN5ZZ8Dc
 UOA==
X-Gm-Gg: ASbGncu4Y/IkI+XT/zqnuApe1yX/1Hz9xrMaTzG1vSKe9aa+BzTE5ChYjV/Y6rnJZvM
 ZnGhFpW/A4jBKJhqXxBV63SRDS/ycEAAcuHlandY5i9W++EkXZYZ8+CXINfbJQzfH0wD84nLQFL
 bjmitQpfW65jfaxmFaxVPDqxdAODtU88vbTHbGIcwoQ9mlWhXG1SDvPoTholjDREL4mT/zVFDSM
 7S2rmgNwi4o3lSODJBBZpLlb+yNbndNuoaPsZEX1V4u8ED1QGSpHZV72ElXiAgWJcqfnKDMDUr2
 Flf/Lc0Bbnz303ld85zeMrTRkN7o5l9YNFXjmYK8EBA5oLodFQ5rFhTtWRv+WPh8bQb4F3DvIA=
 =
X-Google-Smtp-Source: AGHT+IGAie3RZY4P350QczEu7M7qNMV5m6bxwy/Q8txJ6as8w3iDOYGOnN9Qib1i9SIZFxVt9WB3gA==
X-Received: by 2002:a05:6512:3c8d:b0:545:e2e:843a with SMTP id
 2adb3069b0e04-54e9db15883mr589021e87.38.1745912953899; 
 Tue, 29 Apr 2025 00:49:13 -0700 (PDT)
Received: from localhost (host-97-144.parnet.fi. [77.234.97.144])
 by smtp.gmail.com with ESMTPSA id
 2adb3069b0e04-54e7ccb7cdesm1808894e87.210.2025.04.29.00.49.13
 for <ffmpeg-devel@ffmpeg.org>
 (version=TLS1 cipher=AES128-SHA bits=128/128);
 Tue, 29 Apr 2025 00:49:13 -0700 (PDT)
From: =?UTF-8?q?Martin=20Storsj=C3=B6?= <martin@martin.st>
To: ffmpeg-devel@ffmpeg.org
Date: Tue, 29 Apr 2025 10:49:12 +0300
Message-Id: <20250429074913.40779-1-martin@martin.st>
X-Mailer: git-send-email 2.39.5 (Apple Git-154)
MIME-Version: 1.0
Subject: [FFmpeg-devel] [PATCH] configure: Enable -fno-common for Darwin
 targets, avoid linker warnings
X-BeenThere: ffmpeg-devel@ffmpeg.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: FFmpeg development discussions and patches <ffmpeg-devel.ffmpeg.org>
List-Unsubscribe: <https://ffmpeg.org/mailman/options/ffmpeg-devel>,
 <mailto:ffmpeg-devel-request@ffmpeg.org?subject=unsubscribe>
List-Archive: <https://ffmpeg.org/pipermail/ffmpeg-devel>
List-Post: <mailto:ffmpeg-devel@ffmpeg.org>
List-Help: <mailto:ffmpeg-devel-request@ffmpeg.org?subject=help>
List-Subscribe: <https://ffmpeg.org/mailman/listinfo/ffmpeg-devel>,
 <mailto:ffmpeg-devel-request@ffmpeg.org?subject=subscribe>
Reply-To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: ffmpeg-devel-bounces@ffmpeg.org
Sender: "ffmpeg-devel" <ffmpeg-devel-bounces@ffmpeg.org>
Archived-At: <https://master.gitmailbox.com/ffmpegdev/20250429074913.40779-1-martin@martin.st/>
List-Archive: <https://master.gitmailbox.com/ffmpegdev/>
List-Post: <mailto:ffmpegdev@gitmailbox.com>

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".