Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1j2ZOe-0000VA-1H for mharc-grub-devel@gnu.org; Fri, 14 Feb 2020 06:44:36 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54607) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j2ZOc-0000V3-1b for grub-devel@gnu.org; Fri, 14 Feb 2020 06:44:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j2ZOa-0005ni-Bv for grub-devel@gnu.org; Fri, 14 Feb 2020 06:44:33 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:46402 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j2ZOa-0005c7-3C for grub-devel@gnu.org; Fri, 14 Feb 2020 06:44:32 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581680670; 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; bh=Rf+s4UFcQ59AmCbBdMr0/AEw4elCwgRLZ1CGNbMamkw=; b=G2/trReTs5IAViAd37wyv3a3nDr/ZF0+ZWGv9X5ODW6kH9vUyKmUPvxn4ZuJoyUWXgY5qm WTsm4j+CFuJHxlad336OQiU2hfyfain5UZOe0J2fpoNctZ075LQZzwp/FqdW3HnWZea3NY rprNDdY2r4xucK9OEDQ+yxrpuqdO96k= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-428-wcRdstCCOluwjdqYHkJ4Gg-1; Fri, 14 Feb 2020 06:44:24 -0500 Received: by mail-wr1-f72.google.com with SMTP id a12so3880664wrn.19 for ; Fri, 14 Feb 2020 03:44:24 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=rmFB/79Swi91SASl619q0sSbxyJzg+q0zeIDu35Vog4=; b=INWv+ZHXZQBVd2caT2cQFvUPXMSsSBm4koc1/nBU4x7O6eNwzreTuRDsTRudsy2RZ0 Hi+VCm8yEaNNvnawi453qWaBXxATc+vrJneKUGRzlhQ5nYcLCohCtTjTDvXHS1LhS3wT rzw1DHTIRvWw2NRkQ9bu5NDlPrTB/xl6AUFqI3DMqh2RFy6CbyjHMOs745fTLAEbDLoX w5luEAz4xqjr/z3Nq7nioJgyR73lgWn0iejWbtPIvxoV3ad23EBGNrkxOUgDKMiSTbkL +SjAXg3OsEXqCGsmgqFIXv7PnVpNWg5xqxBy7LADGp4clZ2F+bidnoMTFjpEcBPUdF1E KSPg== X-Gm-Message-State: APjAAAXHRSQZOH6sVSrK+bG/Huezn08oKzMO8lD2gFYW2QvIQXGR1ms8 ClmOigCSEN6EgkOxQLp/U5ZXytwgKItsOzhKftzg0xRKNs1A0f45SqiWMCkHj7hRoLKm/KU2ZiF 8GuIcrzhbf6Q= X-Received: by 2002:adf:e742:: with SMTP id c2mr3700999wrn.346.1581680662623; Fri, 14 Feb 2020 03:44:22 -0800 (PST) X-Google-Smtp-Source: APXvYqzblqvFdkstAlD4yoKvwJEsWuCXfEkQxCfeb8xsJ0aX3wvVH8sT8/om64djfILjc+wmsoXTwA== X-Received: by 2002:adf:e742:: with SMTP id c2mr3700978wrn.346.1581680662349; Fri, 14 Feb 2020 03:44:22 -0800 (PST) Received: from minerva.redhat.com ([2a01:c50f:ab80:6700:527f:85b3:5615:ff0b]) by smtp.gmail.com with ESMTPSA id z25sm7029790wmf.14.2020.02.14.03.44.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Feb 2020 03:44:21 -0800 (PST) From: Javier Martinez Canillas To: grub-devel@gnu.org Cc: Juergen Gross , Vladimir Serbinenko , Daniel Kiper , Javier Martinez Canillas Subject: [PATCH] normal: Move common datetime functions out of the normal module Date: Fri, 14 Feb 2020 12:44:14 +0100 Message-Id: <20200214114414.1843607-1-javierm@redhat.com> X-Mailer: git-send-email 2.24.1 MIME-Version: 1.0 X-MC-Unique: wcRdstCCOluwjdqYHkJ4Gg-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.61 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Feb 2020 11:44:35 -0000 The common datetime helper functions are currently included in the normal module, but this makes any other module that calls these functions to have a dependency with the normal module only for this reason. Since the normal module does a lot of stuff, it calls functions from other modules. But since other modules may depend on it for calling the datetime helpers, this could lead to circular dependencies between modules. As an example, when platform =3D=3D xen the grub_get_datetime() function fr= om the datetime module calls to the grub_unixtime2datetime() helper function from the normal module. Which leads to the following module dependency: datetime -> normal and send_dhcp_packet() from the net module calls the grub_get_datetime() function, which leads to the following module dependency: net -> datetime -> normal but that means that the normal module is not allowed to depend on net or any other module that depends on it due the transitive dependency caused by datetime. A recent patch attempted to add support to fetch the config file over the network, which leads to the following circular dependency: normal -> net -> datetime -> normal So having the datetime helpers in the normal module makes it quite fragile and easy to add circular dependencies like these, that break the build due the genmoddep.awk script catching the issues. Fix this by taking the datetime helper functions out of the normal module and instead add them to the datetime module itself. Besides fixing these issues, it makes more sense to have these helper functions there anyways. Reported-by: Daniel Kiper Signed-off-by: Javier Martinez Canillas --- Hello Daniel, I dig into the error you mentioned was happening when trying to build the "[PATCH v6 0/5] Search for specific config files using UUID, MAC and IP" patch-set. This was caused by making the normal module to depend on the net module and this module in turn depending on normal through the datetime module. The patch fixes the issue for me, after this I can successufully build the patch-set with the --with-platform=3Dxen configure option. Best regards, Javier Makefile.util.def | 2 +- grub-core/Makefile.core.def | 2 +- grub-core/{normal =3D> lib}/datetime.c | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename grub-core/{normal =3D> lib}/datetime.c (100%) diff --git a/Makefile.util.def b/Makefile.util.def index 94336392b9e..174877c41b8 100644 --- a/Makefile.util.def +++ b/Makefile.util.def @@ -141,7 +141,7 @@ library =3D { common =3D grub-core/lib/crc.c; common =3D grub-core/lib/adler32.c; common =3D grub-core/lib/crc64.c; - common =3D grub-core/normal/datetime.c; + common =3D grub-core/lib/datetime.c; common =3D grub-core/normal/misc.c; common =3D grub-core/partmap/acorn.c; common =3D grub-core/partmap/amiga.c; diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index a0507a1fa4c..91297e4ebfe 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -1687,6 +1687,7 @@ module =3D { =20 module =3D { name =3D datetime; + common =3D lib/datetime.c; cmos =3D lib/cmos_datetime.c; efi =3D lib/efi/datetime.c; uboot =3D lib/dummy/datetime.c; @@ -1926,7 +1927,6 @@ module =3D { common =3D normal/autofs.c; common =3D normal/color.c; common =3D normal/completion.c; - common =3D normal/datetime.c; common =3D normal/menu.c; common =3D normal/menu_entry.c; common =3D normal/menu_text.c; diff --git a/grub-core/normal/datetime.c b/grub-core/lib/datetime.c similarity index 100% rename from grub-core/normal/datetime.c rename to grub-core/lib/datetime.c --=20 2.24.1