From nobody Tue Feb 10 04:15:22 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1666101025; cv=none; d=zohomail.com; s=zohoarc; b=W/OGg5l6rS5tABMeRl4QsuzoRjzv4iu0QwOXVGGbVRkd7tttnRHaNyHjuczGrDNjxay2qbIn+mYt2CoX/p4hvnVBcZ5TXR4T0RwP1N8eGM5Ut5gyUDpOFFC8XC6gbUlBRd/fUUCa3qve+a5cCnXK1CjogJ0zwpAAX2x87228KKg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666101025; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=oE+3E3jGm4iDUWdYfIF6C9CXXTBvieh4iAWsUTJZKNI=; b=m4Qzk1IaiSwN7mNftvKN2Fu2a+8v5qe1kmqdam1o0MudF1IIgRaxqT6brPXq0+BjwUWNXZJQVZ3OUQKON+QIgxlCNSS0S3knlPGfT4y4r2QbVkKXw0pi2B+cgttEbKwi+qmr2TVTXbNCf2SeVhUGujP9bZVkMeaaJ2ZhZdgEZYU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 166610102573921.10354623078183; Tue, 18 Oct 2022 06:50:25 -0700 (PDT) Received: from localhost ([::1]:52468 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1okmzA-0006T4-4n for importer@patchew.org; Tue, 18 Oct 2022 09:50:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57512) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okmgh-0002KC-7z for qemu-devel@nongnu.org; Tue, 18 Oct 2022 09:31:23 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:33765) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okmga-000504-MJ for qemu-devel@nongnu.org; Tue, 18 Oct 2022 09:31:17 -0400 Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-577-0mN55wOLO4G8Osntzo1KiQ-1; Tue, 18 Oct 2022 09:31:10 -0400 Received: by mail-ed1-f69.google.com with SMTP id c9-20020a05640227c900b0045d4a88c750so6973093ede.12 for ; Tue, 18 Oct 2022 06:31:10 -0700 (PDT) Received: from avogadro.local ([2001:b07:6468:f312:2f4b:62da:3159:e077]) by smtp.gmail.com with ESMTPSA id sz15-20020a1709078b0f00b0078d9b967962sm7418575ejc.65.2022.10.18.06.31.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Oct 2022 06:31:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666099872; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oE+3E3jGm4iDUWdYfIF6C9CXXTBvieh4iAWsUTJZKNI=; b=M58V63JBrDFLdXpRM5aTGroEe7bHB2t3naYDvDVpHuoCFRZ+vDuGXkOYrdG0stU7CoqG58 oF4nkjmSj2UtBfK3CdYv1wEF+kklrvAOJaY4sI7h8oVhV2PJ+pXbavE1mTub7zUisTP2+X WABfbKKtNhw/MbPt3kS90u3J62tjDvg= X-MC-Unique: 0mN55wOLO4G8Osntzo1KiQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oE+3E3jGm4iDUWdYfIF6C9CXXTBvieh4iAWsUTJZKNI=; b=5xguZYY5kA/Id43DYaOi/rBvLCSimrzcW10piDrEX0CXunP22DEMv8GPc4cmcvTF2k YFlay1DEwqy7uN0jMjHVbip3nLvpQp3mZUWjUzt9glh/hytJcmmfIV28s1YHu60Za/qw BKPNBYCzGlmCORKfZpfaKzhvldeJlAfC/jQU0/LrcyNaDUix772CRvk0Uni9jfECshNf +JBhZpWF4mphm97cexcsKt8uxQi3fVvmE214HbMdvOkqH+JkzIVEaumLNzQ4II5RXYb8 skcOch3kAAD5vnT9B603o9IUGpc9OpKp0mJQJXDiM/6vIrOjyS4qW0HpgFUPrBQn4VBD kmcA== X-Gm-Message-State: ACrzQf0gL2+0KqT+aehklENYMdEKnfDmhb/9/XPpPGpdIiukbBrIZ/HZ KKWKIrIxPIL8PS2GTGcjVZTOZvj3LYH0+1BJwSCVaFdN2jhszZOEKFUq+2LbM1LAaxNG22KiHmV f9TmzExmqR4EfQsNLU44FjIMwi9avzzye46mtWD9XJUys1xuY/RnCHs6S53CLaLLK62c= X-Received: by 2002:a17:907:e87:b0:78e:2b3c:f672 with SMTP id ho7-20020a1709070e8700b0078e2b3cf672mr2442009ejc.74.1666099868695; Tue, 18 Oct 2022 06:31:08 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6O6U19SyyzRj1WVbO1Be7mCNSSXm5/yGMq4x+uQwWIZXufy936ztrkFyr8dXkqSkYAQfVmjQ== X-Received: by 2002:a17:907:e87:b0:78e:2b3c:f672 with SMTP id ho7-20020a1709070e8700b0078e2b3cf672mr2441985ejc.74.1666099868379; Tue, 18 Oct 2022 06:31:08 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Michal Privoznik , qemu-stable@nongnu.org Subject: [PULL 06/53] configure: Avoid using strings binary Date: Tue, 18 Oct 2022 15:29:55 +0200 Message-Id: <20221018133042.856368-7-pbonzini@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221018133042.856368-1-pbonzini@redhat.com> References: <20221018133042.856368-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.256, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1666101026871100002 Content-Type: text/plain; charset="utf-8" From: Michal Privoznik When determining the endiandness of the target architecture we're building for a small program is compiled, which in an obfuscated way declares two strings. Then, we look which string is in correct order (using strings binary) and deduct the endiandness. But using the strings binary is problematic, because it's part of toolchain (strings is just a symlink to x86_64-pc-linux-gnu-strings or llvm-strings). And when (cross-)compiling, it requires users to set the symlink to the correct toolchain. Fortunately, we have a better alternative anyways. We can mimic what compiler.h is already doing: comparing __BYTE_ORDER__ against values for little/big endiandness. Bug: https://bugs.gentoo.org/876933 Signed-off-by: Michal Privoznik Message-Id: Cc: qemu-stable@nongnu.org Signed-off-by: Paolo Bonzini --- configure | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/configure b/configure index f9ec050bf8..81561be7c1 100755 --- a/configure +++ b/configure @@ -1423,30 +1423,31 @@ if test "$tcg" =3D "enabled"; then git_submodules=3D"$git_submodules tests/fp/berkeley-softfloat-3" fi =20 -# --- +########################################## # big/little endian test cat > $TMPC << EOF -#include -short big_endian[] =3D { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, }; -short little_endian[] =3D { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41= , 0, }; -int main(int argc, char *argv[]) -{ - return printf("%s %s\n", (char *)big_endian, (char *)little_endian); -} +#if defined(__BYTE_ORDER__) && __BYTE_ORDER__ =3D=3D __ORDER_LITTLE_ENDIAN= __ +# error LITTLE +#endif +int main(void) { return 0; } EOF =20 -if compile_prog ; then - if strings -a $TMPE | grep -q BiGeNdIaN ; then - bigendian=3D"yes" - elif strings -a $TMPE | grep -q LiTtLeEnDiAn ; then - bigendian=3D"no" - else - echo big/little test failed - exit 1 - fi +if ! compile_prog ; then + bigendian=3D"no" else + cat > $TMPC << EOF +#if defined(__BYTE_ORDER__) && __BYTE_ORDER__ =3D=3D __ORDER_BIG_ENDIAN__ +# error BIG +#endif +int main(void) { return 0; } +EOF + + if ! compile_prog ; then + bigendian=3D"yes" + else echo big/little test failed exit 1 + fi fi =20 ########################################## --=20 2.37.3