From patchwork Thu May 29 00:03:31 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 353627 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id B0B8314009C for ; Thu, 29 May 2014 10:03:44 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type; q=dns; s= default; b=Sr9giTewO+MqMhgxnCTDxhweC5IkeYb1N8xeSMZ/gMfi6fJy6PjSj JOA5dvO8BXitcHIJn6Q0fyUWs1IkzQ2eFzSUfQNSKJm8bal3Qe2DTeto2QsAzGem VCbGL42oMxlFACkqdoSQ9fVz4liZovw066ihq+gufavuB3EBw0czSU= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type; s= default; bh=4Ot0VfJA4mYDvVSRuuy2wqAlUuA=; b=TRI+IGLkoZ+ukOgKNYOT zODYpfnkar6tn0SrY6rULRP2uVcENH/JyN5fl2hYjmgiVQP0QKiCMd5Mlfe3tmCF aUKIMn1A2x+IdcR3iLgaP88tA5EIwIMwBmlucWDvIHqkoQq0I8hAZU3xlXX1BaTA BeGh8mpgtk36HUn1hQTHHvA= Received: (qmail 31726 invoked by alias); 29 May 2014 00:03:37 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 31715 invoked by uid 89); 29 May 2014 00:03:37 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.1 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, RP_MATCHES_RCVD, SPF_PASS, T_TVD_MIME_NO_HEADERS, UNSUBSCRIBE_BODY autolearn=no version=3.3.2 X-HELO: mail-pb0-f51.google.com Received: from mail-pb0-f51.google.com (HELO mail-pb0-f51.google.com) (209.85.160.51) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Thu, 29 May 2014 00:03:36 +0000 Received: by mail-pb0-f51.google.com with SMTP id ma3so12042250pbc.38 for ; Wed, 28 May 2014 17:03:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:user-agent :mime-version:content-type; bh=0WqC0jO0Xz1MqqOBKYs3jkVIih2+WnZhPM3QXBcvDUo=; b=Mnw54sv9ioyiC29gA/Mc4RQKM4mog9q+EBF7qLhAaep2NqKZFyYa0QmyBYnmVnEhO2 ag8jjHrnhhsbUVZvpL9xSdtwHXsagdbhdgdJCHsjMWCZhzTwfNZhdpm8RmIz0shIEe6z Mv+HUZDGWg+Rl53fUKCzjV1SQ0rxMzCpC4EMHWt9/vREl1sK1E/ub5WjOJLSwJa5rNmL yfqii8eltG9bdz61gHNPLkEEWVXAOds247a7FfpOQe9DxsIrJYvnbDB3QbVjw9Y2SlNc GckMm3DXT8bWBtBuSLMgfXbHDTrl5PbRlIGMtqyvGL1I/2/ZUbx/AB4osXOSPKvv3tpd NpLw== X-Gm-Message-State: ALoCoQnRUphqbHDKqPwT6HySzV9jbAQZzkpQucXmNsQPON1j/wVyPLX/kh4UvhysQikvetRSYDv1 X-Received: by 10.66.65.204 with SMTP id z12mr3930608pas.60.1401321814590; Wed, 28 May 2014 17:03:34 -0700 (PDT) Received: from iant-glaptop.roam.corp.google.com.google.com ([207.198.105.20]) by mx.google.com with ESMTPSA id hb10sm30259154pbd.75.2014.05.28.17.03.33 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 28 May 2014 17:03:33 -0700 (PDT) From: Ian Lance Taylor To: gcc-patches@gcc.gnu.org, gofrontend-dev@googlegroups.com Subject: libgo patch committed: Work around LLVM split-stack deficiency Date: Wed, 28 May 2014 17:03:31 -0700 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) MIME-Version: 1.0 X-IsSubscribed: yes This patch from Peter Collingbourne tweaks libgo to work around a deficiency in the LLVM split-stack implementation: it doesn't support varargs functions. This is a step toward making it possible to compile libgo with LLVM. Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu. Committed to mainline. Ian diff -r 445501e362dd libgo/runtime/print.c --- a/libgo/runtime/print.c Wed May 28 16:10:26 2014 -0700 +++ b/libgo/runtime/print.c Wed May 28 16:47:30 2014 -0700 @@ -11,7 +11,9 @@ //static Lock debuglock; -static void go_vprintf(const char*, va_list); +// Clang requires this function to not be inlined (see below). +static void go_vprintf(const char*, va_list) +__attribute__((noinline)); // write to goroutine-local buffer if diverting output, // or else standard error. @@ -61,6 +63,24 @@ gwrite(s, runtime_findnull((const byte*)s)); } +#if defined (__clang__) && (defined (__i386__) || defined (__x86_64__)) +// LLVM's code generator does not currently support split stacks for vararg +// functions, so we disable the feature for this function under Clang. This +// appears to be OK as long as: +// - this function only calls non-inlined, internal-linkage (hence no dynamic +// loader) functions compiled with split stacks (i.e. go_vprintf), which can +// allocate more stack space as required; +// - this function itself does not occupy more than BACKOFF bytes of stack space +// (see libgcc/config/i386/morestack.S). +// These conditions are currently known to be satisfied by Clang on x86-32 and +// x86-64. Note that signal handlers receive slightly less stack space than they +// would normally do if they happen to be called while this function is being +// run. If this turns out to be a problem we could consider increasing BACKOFF. +void +runtime_printf(const char *s, ...) +__attribute__((no_split_stack)); +#endif + void runtime_printf(const char *s, ...) {