From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id CB4A63858D35 for ; Thu, 3 Aug 2023 15:47:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CB4A63858D35 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1691077642; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=G1CzdM5TdutdYypDIgJKREVse3xgxjIYIbbGZmkGjC4=; b=DrE36qE7GoZI3MxDkhaGntiZTKOn3gRPCrad41TN/2Wd/TUxUPZH8r+TJ+IFprUaGCqjZ0 dfATebnhkDanUPCNO0ONJ9lA5Nix+7kvL+Leht3FzxPVTvoI3OPJKc8RnEmcRZmR09UMg/ YcTvZ2wNQjAZtjNJsROPlKw+TDv9VPQ= Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-237-CnTfNzkTPi6G07rU4-VaEg-1; Thu, 03 Aug 2023 11:47:21 -0400 X-MC-Unique: CnTfNzkTPi6G07rU4-VaEg-1 Received: by mail-qt1-f200.google.com with SMTP id d75a77b69052e-40831789e55so12334381cf.1 for ; Thu, 03 Aug 2023 08:47:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691077640; x=1691682440; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=G1CzdM5TdutdYypDIgJKREVse3xgxjIYIbbGZmkGjC4=; b=PdogkpZIt5GzTMYtzfB9mirQKHnmlWPcXMwUChMwtfCJR1J8BaD/OBv8HrlA4EiyrY SKdmyhxhIiMR9d5aCZloM80ytbK6O1bxzEgkTURHpjGaWrywmQqMoLEE/oopfSbGWQp7 y6J4TtbPe5O0MyFMQzYNnAphYKF41Me7i0aUCGyeYFBaMwsR1SkhIKpLtvct98JrXK3P O2hZfcvyEFUndM87hr70/aI3pi9+dc2tqPVsWdQ+JhHx4OosGEc5ymJWwqpWL+044J8H k0Oelo+u36TUxctCV9vjkXeUdB6rWka47hTamQpFCYBrQ6mbGybm0QqoY0VpKqYmEqEO Zgqw== X-Gm-Message-State: ABy/qLbDIpH77K/JzFBXTVKjFxTRe7kSriIOSOFwqWdU/rzz+J9rrxL7 4hWYKixDDdG8Rnp9RXmaWL/C5iaLosRDj8EaHPdrH8iCZxSAIbNrr8pvpuydveHjPLR9B6R4JHx mTKbS86E= X-Received: by 2002:ac8:5e51:0:b0:406:94f8:ee14 with SMTP id i17-20020ac85e51000000b0040694f8ee14mr23308618qtx.67.1691077640034; Thu, 03 Aug 2023 08:47:20 -0700 (PDT) X-Google-Smtp-Source: APBJJlHmF04DyHv5XfN8weDneBshooTnOlFJeamlDlXmRbg7rIpHTCfTjTnK5M82YK6bCkTwBO7YFw== X-Received: by 2002:ac8:5e51:0:b0:406:94f8:ee14 with SMTP id i17-20020ac85e51000000b0040694f8ee14mr23308603qtx.67.1691077639727; Thu, 03 Aug 2023 08:47:19 -0700 (PDT) Received: from t14s.localdomain (c-76-28-97-5.hsd1.ma.comcast.net. [76.28.97.5]) by smtp.gmail.com with ESMTPSA id a16-20020ac87210000000b00403f4459e33sm11940qtp.91.2023.08.03.08.47.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Aug 2023 08:47:19 -0700 (PDT) Message-ID: Subject: Re: JIT function compile to file From: David Malcolm To: "Li, Yicheng" , "jit@gcc.gnu.org" Date: Thu, 03 Aug 2023 11:47:18 -0400 In-Reply-To: <1A45981A-5FCC-4B7A-9586-85F3315169C2@vols.utk.edu> References: <1A45981A-5FCC-4B7A-9586-85F3315169C2@vols.utk.edu> User-Agent: Evolution 3.44.4 (3.44.4-2.fc36) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-5.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,KAM_SHORT,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Thu, 2023-08-03 at 15:07 +0000, Li, Yicheng via Jit wrote: > Hi, >=20 > I=E2=80=99m looking for examples that can let me build a jit function on = one > run, save it to a file, and grab from file again on the second run > without rebuilding and recompilation. > I=E2=80=99ve seen the function, gcc_jit_context_compile_to_file, and I=E2= =80=99m > wondering how to use it. gcc_jit_context_compile_to_file is for ahead-of-time compilation. You could compile the function into a shared library, and then load the shared library when the process restarts. Emacs does something like this for its Lisp files; see: https://akrl.sdf.org/gccemacs.html > Throughout the documentation, I see the gcc_jit_location type > variable, I=E2=80=99m unsure how to use it, and if it is related to calli= ng a > saved-to-file jit function. gcc_jit_location is for providing "source location" information for use when stepping through the code in a debugger. It doesn't affect the destination where code is compiled to. > It would be great if there=E2=80=99s any example that can be provided. I don't think there's an existing example in the documentation or testsuite, but use gcc_jit_context_compile_to_file with GCC_JIT_OUTPUT_KIND_DYNAMIC_LIBRARY to make a .so file, then on rerunning the process use dlopen to load the .so file, and dlsym to extract the function. FWIW the testsuite has:https://gcc.gnu.org/git/?p=3Dgcc.git;a=3Dblob;f=3Dgcc/testsuite/jit.dg/= test-compile-to-dynamic-library.c but that testcase merely does the compilation-to-dynamic-library, not the loading of the built library, and it heavily uses the preprocessor so probably isn't good as an example. Hope this is helpful Dave