From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B68E2C433DF for ; Wed, 29 Jul 2020 19:14:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9398F2075F for ; Wed, 29 Jul 2020 19:14:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="SirHb7v8" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726615AbgG2TOB (ORCPT ); Wed, 29 Jul 2020 15:14:01 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:49977 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726535AbgG2TOB (ORCPT ); Wed, 29 Jul 2020 15:14:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1596050039; 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=NzkIVUL202BpSE2crdCXpv2sXPZapzvMGItiUxe0cmY=; b=SirHb7v8hvht/K7YEjwk44BjedGPv4h3A0ZoUKnLlbeIT6ty8rNP67zLA5uffpSw4IjZm9 a1GMnlF02I5HWrPn/pF22VihB6QaJkGZxKAS2fP6hxYVOIIS910j9XnT9zHOTkjr4z5kWt Uj2DkQwUYVFWWZw4eQVMwTiW6Ptx5yM= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-491-IfAxil9UPwG_JNLLGJol-w-1; Wed, 29 Jul 2020 15:13:53 -0400 X-MC-Unique: IfAxil9UPwG_JNLLGJol-w-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 311621B18BD8; Wed, 29 Jul 2020 19:13:51 +0000 (UTC) Received: from carbon (unknown [10.40.208.90]) by smtp.corp.redhat.com (Postfix) with ESMTP id CAF955DA77; Wed, 29 Jul 2020 19:13:42 +0000 (UTC) Date: Wed, 29 Jul 2020 21:13:41 +0200 From: Jesper Dangaard Brouer To: Yonghong Song , Andrii Nakryiko , Alexei Starovoitov , Daniel Borkmann , BPF-dev-list , "iovisor-dev@lists.iovisor.org" Cc: brouer@redhat.com, "xdp-newbies@vger.kernel.org" , Arnaldo Carvalho de Melo , Jiri Olsa , Shaun Crampton , steve.langasek@canonical.com, wookey@debian.org, Yonghong Song Subject: Clang target bpf compile issue/fail on Ubuntu and Debian Message-ID: <20200729211341.1a713559@carbon> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Sender: bpf-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org The BPF UAPI header file includes , which gives BPF-programs access to types e.g. __u32, __u64, __u8, etc. On Ubuntu/Debian when compiling with clang option[1] "-target bpf" the compile fails because it cannot find the file , which is included from . This is because Ubuntu/Debian tries to support multiple architectures on a single system[2]. On x86_64 the file is located in /usr/include/x86_64-linux-gnu/, which the distro compiler will add to it's search path (/usr/include/ [3]). Note, it works if not specifying target bpf, but as explained in kernel doc[1] the clang target bpf should really be used (to avoid other issues). There are two workarounds: (1) To have an extra include dir on Ubuntu (which seems too x86 specific) like: CFLAGS += -I/usr/include/x86_64-linux-gnu . Or (2) install the package gcc-multilib on Ubuntu. The question is: Should Ubuntu/Debian have a /usr/include/ directory for BPF? (as part of their multi-arch approach) Or should clang use the compile-host's triplet for the /usr/include/triplet path even when giving clang -target bpf option? p.s. GCC choose 'bpf-unknown-none' target triplet for BPF. Links: [1] https://www.kernel.org/doc/html/latest/bpf/bpf_devel_QA.html#q-clang-flag-for-target-bpf [2] https://wiki.ubuntu.com/MultiarchSpec [3] https://wiki.osdev.org/Target_Triplet -- Best regards, Jesper Dangaard Brouer MSc.CS, Principal Kernel Engineer at Red Hat LinkedIn: http://www.linkedin.com/in/brouer