From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 02D3A383CCCD for ; Mon, 5 Sep 2022 07:31:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 02D3A383CCCD Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.cz Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id B28FB38777; Mon, 5 Sep 2022 07:31:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1662363094; h=from:from:reply-to: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=ahYD4xalIW1nJov0Q4vFRXHz4iwpzxoNDVkXI8HUWYQ=; b=iku3m+y7GCIAAsy0MDyOiMWDO9dItMF2GRkC1kraUQzc9rkTk+Vjdw/se0B7x5PR7cTe2g Oh4khSWJWHSpnGp6IC+XcHLKL7vQ52ZD0J8yUz7X/4I5Q3iIBqjUV/F6Z5iEC6L09kpyyv wyyHTwknooRyIhHhkL66Q/ACxkxNfjM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1662363094; h=from:from:reply-to: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=ahYD4xalIW1nJov0Q4vFRXHz4iwpzxoNDVkXI8HUWYQ=; b=e25rzUFawZTuyHCvpH6BxVxsm+ehh85idcnHXGr9RTTE5Tr2oGEod+/X1uAxzYEzi0xNTJ NaVH1kjuWS7ydvDQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 9F79813A66; Mon, 5 Sep 2022 07:31:34 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id VaqlJdalFWNlcAAAMHmgww (envelope-from ); Mon, 05 Sep 2022 07:31:34 +0000 Message-ID: <6f327916-2160-dbd8-5bef-71172999946a@suse.cz> Date: Mon, 5 Sep 2022 09:31:34 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.1 Subject: Re: libsanitizer: merge from upstream Content-Language: en-US To: Iain Sandoe Cc: GCC Patches References: <10f0f307-2522-fa2f-ae66-e842c76a7f55@suse.cz> <71E19ED7-144A-4DC2-A2DA-6E86AB66597F@sandoe.co.uk> From: =?UTF-8?Q?Martin_Li=c5=a1ka?= In-Reply-To: <71E19ED7-144A-4DC2-A2DA-6E86AB66597F@sandoe.co.uk> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,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 9/4/22 21:50, Iain Sandoe wrote: > Hi Martin, > >> On 30 Aug 2022, at 11:53, Martin Liška wrote: >> >> On 5/4/22 10:59, Martin Liška wrote: >>> Hello. >> I've just done one more merge from upstream. >> Upstream revision: 84a71d5259c2682403cdbd8710592410a2f128ab. > > Which (again) breaks bootstrap on Darwin (since upstream uses features > and APIs not present in GCC and/or supported by the systems we support). Hi. Can you please report that to upstream and create a patch that would be accepted by upstream? Thanks, Martin > > Worked around as below; we will need to find a way to handle the > macOS 13+ changes. > > Iain > > > [pushed] [libsanitizer, Darwin] Fix bootstrap after recent merge. > > The latest merge to libsanitizer includes changes to handle macOS 13+. > However, these changes are incompatible with GCC and so we need to find > an alternate solution. To restore bootstrap back this change out until > the alternate can be found. > --- > .../sanitizer_procmaps_mac.cpp | 62 +++---------------- > 1 file changed, 10 insertions(+), 52 deletions(-) > > diff --git a/libsanitizer/sanitizer_common/sanitizer_procmaps_mac.cpp b/libsanitizer/sanitizer_common/sanitizer_procmaps_mac.cpp > index 4b0e6781976..ba4259acd46 100644 > --- a/libsanitizer/sanitizer_common/sanitizer_procmaps_mac.cpp > +++ b/libsanitizer/sanitizer_common/sanitizer_procmaps_mac.cpp > @@ -146,8 +146,13 @@ static bool IsDyldHdr(const mach_header *hdr) { > // until we hit a Mach header matching dyld instead. These recurse > // calls are expensive, but the first memory map generation occurs > // early in the process, when dyld is one of the only images loaded, > -// so it will be hit after only a few iterations. These assumptions don't hold > -// on macOS 13+ anymore (dyld itself has moved into the shared cache). > +// so it will be hit after only a few iterations. These assumptions don't > +// hold on macOS 13+ anymore (dyld itself has moved into the shared cache). > + > +// FIXME: Unfortunately, the upstream revised version to deal with macOS 13+ > +// is incompatible with GCC and also uses APIs not available on earlier > +// systems which we support; backed out for now. > + > static mach_header *GetDyldImageHeaderViaVMRegion() { > vm_address_t address = 0; > > @@ -171,64 +176,17 @@ static mach_header *GetDyldImageHeaderViaVMRegion() { > } > } > > -extern "C" { > -struct dyld_shared_cache_dylib_text_info { > - uint64_t version; // current version 2 > - // following fields all exist in version 1 > - uint64_t loadAddressUnslid; > - uint64_t textSegmentSize; > - uuid_t dylibUuid; > - const char *path; // pointer invalid at end of iterations > - // following fields all exist in version 2 > - uint64_t textSegmentOffset; // offset from start of cache > -}; > -typedef struct dyld_shared_cache_dylib_text_info > - dyld_shared_cache_dylib_text_info; > - > -extern bool _dyld_get_shared_cache_uuid(uuid_t uuid); > -extern const void *_dyld_get_shared_cache_range(size_t *length); > -extern int dyld_shared_cache_iterate_text( > - const uuid_t cacheUuid, > - void (^callback)(const dyld_shared_cache_dylib_text_info *info)); > -} // extern "C" > - > -static mach_header *GetDyldImageHeaderViaSharedCache() { > - uuid_t uuid; > - bool hasCache = _dyld_get_shared_cache_uuid(uuid); > - if (!hasCache) > - return nullptr; > - > - size_t cacheLength; > - __block uptr cacheStart = (uptr)_dyld_get_shared_cache_range(&cacheLength); > - CHECK(cacheStart && cacheLength); > - > - __block mach_header *dyldHdr = nullptr; > - int res = dyld_shared_cache_iterate_text( > - uuid, ^(const dyld_shared_cache_dylib_text_info *info) { > - CHECK_GE(info->version, 2); > - mach_header *hdr = > - (mach_header *)(cacheStart + info->textSegmentOffset); > - if (IsDyldHdr(hdr)) > - dyldHdr = hdr; > - }); > - CHECK_EQ(res, 0); > - > - return dyldHdr; > -} > - > const mach_header *get_dyld_hdr() { > if (!dyld_hdr) { > // On macOS 13+, dyld itself has moved into the shared cache. Looking it up > // via vm_region_recurse_64() causes spins/hangs/crashes. > + // FIXME: find a way to do this compatible with GCC. > if (GetMacosAlignedVersion() >= MacosVersion(13, 0)) { > - dyld_hdr = GetDyldImageHeaderViaSharedCache(); > - if (!dyld_hdr) { > VReport(1, > - "Failed to lookup the dyld image header in the shared cache on " > - "macOS 13+ (or no shared cache in use). Falling back to " > + "looking up the dyld image header in the shared cache on " > + "macOS 13+ is not yet supported. Falling back to " > "lookup via vm_region_recurse_64().\n"); > dyld_hdr = GetDyldImageHeaderViaVMRegion(); > - } > } else { > dyld_hdr = GetDyldImageHeaderViaVMRegion(); > }