DMARC-Filter: OpenDMARC Filter v1.4.2 delorie.com 51BMQJ74518426 Authentication-Results: delorie.com; dmarc=pass (p=none dis=none) header.from=cygwin.com Authentication-Results: delorie.com; spf=pass smtp.mailfrom=cygwin.com DKIM-Filter: OpenDKIM Filter v2.11.0 delorie.com 51BMQJ74518426 Authentication-Results: delorie.com; dkim=pass (1024-bit key, unprotected) header.d=cygwin.com header.i=@cygwin.com header.a=rsa-sha256 header.s=default header.b=kUf1vM5q X-Recipient: archive-cygwin AT delorie DOT com DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2CF433858C5F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com; s=default; t=1739312779; bh=LD2dm6TJod4KzeCBZ47ENTMUOsH8JNECscA/yJ7rAoY=; h=Date:Subject:To:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=kUf1vM5q7aJ3cy9ni4MJS/NItotRhlOGsnBa6ykBPdxwMp3zY5KfL6qXQQYBR9yKD gKk9sPkd4E4cIOKI+wr8BSKgq+rMNDDH8UB8+1njwC15s/BUPgS5sSf8lLQhTwhqWl Hs8yHiBqgCk5xoBJ4hqdmXyx3PY+Y4CvFbK3vVhs= X-Original-To: cygwin AT cygwin DOT com Delivered-To: cygwin AT cygwin DOT com DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 92AE53858D33 ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 92AE53858D33 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1739312721; cv=none; b=L7yqWOAtlx5E1DKGe2+8PvfZqGWmUarSTWGFbVh33Y92TeyEGx5QkZZutR7jkn2dSK/G0vd0rkZuROW9/AIc8YWhSc+Ucmeiwqa1Ohb2cbs5KcLfheBKFs9u6tKtDJIFIQj/9EE6pGl7iwXHRLS0JrxkQBTHa5rL0ihsjNwnPiQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1739312721; c=relaxed/simple; bh=1yC4oG2OHbCWx9co4AzJAD06yLWDSiR5aUiBTjR+CoY=; h=Message-ID:Date:MIME-Version:From:Subject:To:DKIM-Signature; b=GSIjZPTxX9SLJOVgL6SQDmRNHhgxGFh0iJqCad/FmFCDy0KJthoGlU3zVyT6+T6+ottQgZ032u3lNAGpPwfaTgSnFm++yUrno0P6NecOiQEozg5DeRL7UIWisGm+F80lU+TXE4qfzc5Nn+9C174fInJRwTqTkzRrklRsdHjoN9o= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 92AE53858D33 Message-ID: <87935cbb-4a43-4ebd-b8cb-125ecfcbcdc3@SystematicSW.ab.ca> Date: Tue, 11 Feb 2025 15:25:18 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: __builtin_thread_pointer Content-Language: en-CA To: The Cygwin Mailing List References: <9c6a1ccc-d2fb-4aaf-b8c2-29574fa640b4 AT cornell DOT edu> <6faedefc-eb17-4b02-89b9-44b73e82d43f AT SystematicSW DOT ab DOT ca> <0252F948-10C3-4B9E-943D-ACA35E190726 AT unified-streaming DOT com> Autocrypt: addr=Brian DOT Inglis AT SystematicSW DOT ab DOT ca; keydata= xjMEXopx8xYJKwYBBAHaRw8BAQdAnCK0qv/xwUCCZQoA9BHRYpstERrspfT0NkUWQVuoePbN LkJyaWFuIEluZ2xpcyA8QnJpYW4uSW5nbGlzQFN5c3RlbWF0aWNTdy5hYi5jYT7ClgQTFggA PhYhBMM5/lbU970GBS2bZB62lxu92I8YBQJeinHzAhsDBQkJZgGABQsJCAcCBhUKCQgLAgQW AgMBAh4BAheAAAoJEB62lxu92I8Y0ioBAI8xrggNxziAVmr+Xm6nnyjoujMqWcq3oEhlYGAO WacZAQDFtdDx2koSVSoOmfaOyRTbIWSf9/Cjai29060fsmdsDM44BF6KcfMSCisGAQQBl1UB BQEBB0Awv8kHI2PaEgViDqzbnoe8B9KMHoBZLS92HdC7ZPh8HQMBCAfCfgQYFggAJhYhBMM5 /lbU970GBS2bZB62lxu92I8YBQJeinHzAhsMBQkJZgGAAAoJEB62lxu92I8YZwUBAJw/74rF IyaSsGI7ewCdCy88Lce/kdwX7zGwid+f8NZ3AQC/ezTFFi5obXnyMxZJN464nPXiggtT9gN5 RSyTY8X+AQ== Organization: Systematic Software In-Reply-To: <0252F948-10C3-4B9E-943D-ACA35E190726@unified-streaming.com> X-Rspamd-Queue-Id: 4C0782002D X-Rspamd-Server: rspamout04 X-Stat-Signature: uq4htnzq8kp9k6i91dujdh1yg56izhct X-Session-Marker: 427269616E2E496E676C69734053797374656D6174696353572E61622E6361 X-Session-ID: U2FsdGVkX1/0LisqWCZCNn1i6VuxKvdaEg2/N6C9DdE= X-HE-Tag: 1739312719-537690 X-HE-Meta: U2FsdGVkX18kw2sTSOgubpon1gFZJj2oZB4hu+7rx22XLb/KAcMSc3IARBdyWCGFkPX2x6IIj5SKJtQRpOavPohW6QAM4a7iuh0hxEzZdrkHQ50pFeBTLu1Dg7QmGxfW+G9kvKqtg1/FoewTSKExgvHIVbB1PTPT56KaWONnkv4/J3G5H1lcMtLc4iRhbDv140edKNi8wug0TPnTcAMOfJOSXDoEUGYgAEvNL0WEm7E9zOGC8Wct3xAuiUaDnDTaWLVqR4qrRbD5jDlR+U92chtifv6ofxdP/BSEhJHkPYFE4jUO8InYwWMPLkRYVLxMNJOIiRpiZYbPiE4uiYE6rPDy1are0TXXAXw4cm8LG515WX72wNUI+w== X-BeenThere: cygwin AT cygwin DOT com X-Mailman-Version: 2.1.30 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Brian Inglis via Cygwin Reply-To: cygwin AT cygwin DOT com Cc: Brian Inglis Content-Type: text/plain; charset="utf-8"; Format="flowed" Errors-To: cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com Sender: "Cygwin" Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by delorie.com id 51BMQJ74518426 On 2025-02-11 13:58, Dimitry Andric wrote: >> On 11 Feb 2025, at 21:45, Brian Inglis via Cygwin wrote: >> On 2025-02-11 12:41, Dimitry Andric via Cygwin wrote: >>>> On 11 Feb 2025, at 20:26, Ken Brown via Cygwin wrote: >>>> Does Cygwin support __builtin_thread_pointer? I'm guessing not, because >>>> I'm getting a link error (undefined reference to >>>> `__builtin_thread_pointer') when I try to build some software that uses >>>> it. Or is there something that would have to be added to the link command >>>> line? The full command line and error message are quoted below, in case >>>> anyone spots something obvious. >> >>> It's a gcc builtin function, not something implemented in an external library. Therefore, there is no linker option that can fix this. >>> Also, as far as I can see from gcc's documentation, >>> __builtin_thread_pointer() is only supported for the RISCV and SH >>> architectures. Then again, gcc's implementation seems to hinge this on >>> whether the platform supports TLS or not. >>> In any case, it is probably better to not use this function if your gcc does >>> not support it. >> Does `info gcc tls` help and do we know if that is supported by our gcc(s)? > It does not look like it's supported by Cygwin's gcc: > $ gcc -v > Using built-in specs. > COLLECT_GCC=gcc > COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-cygwin/12/lto-wrapper.exe > Target: x86_64-pc-cygwin > Configured with: /mnt/share/cygpkgs/gcc/gcc.x86_64/src/gcc-12.4.0/configure --srcdir=/mnt/share/cygpkgs/gcc/gcc.x86_64/src/gcc-12.4.0 --prefix=/usr --exec-prefix=/usr --localstatedir=/var --sysconfdir=/etc --docdir=/usr/share/doc/gcc --htmldir=/usr/share/doc/gcc/html -C --build=x86_64-pc-cygwin --host=x86_64-pc-cygwin --target=x86_64-pc-cygwin --without-libiconv-prefix --without-libintl-prefix --libexecdir=/usr/lib --with-gcc-major-version-only --enable-shared --enable-shared-libgcc --enable-static --enable-version-specific-runtime-libs --enable-bootstrap --enable-__cxa_atexit --enable-clocale=newlib --with-dwarf2 --with-tune=generic --enable-languages=ada,c,c++,fortran,lto,objc,obj-c++,jit --enable-graphite --enable-threads=posix --enable-libatomic --enable-libgomp --enable-libquadmath --enable-libquadmath-support --disable-libssp --enable-libada --disable-symvers --disable-multilib --with-gnu-ld --with-gnu-as --with-cloog-include=/usr/include/cloog-isl --without-libiconv-prefix --without-libintl-prefix --with-system-zlib --enable-linker-build-id --with-default-libstdcxx-abi=gcc4-compatible --enable-libstdcxx-filesystem-ts > Thread model: posix > Supported LTO compression algorithms: zlib zstd > gcc version 12.4.0 (GCC) > On Ubuntu 24.04 this program compiles without warnings. On which platform - RISCV or SH? > It looks like the gcc configure script checks for TLS here: https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/configure.ac;h=8fab93c9365496062583c5bd8ace402c8a797817;hb=HEAD#l3846, by running some code through the assembler. I would guess that doesn't work on Cygwin. It should as gas supports storage class 'T' for thread, and GCC supports and uses posix threads. This compiles just fine under Cygwin: /* test-thread-storage.c */ int f(int *np, char *cp) { static __thread int n; static __thread char *p; int i; n = *np; p = cp; for (i = 0; i < n; ++i) *cp++ = *p++; return i; } Cygwin and GCC support POSIX threads, and they are used in many Cygwin packages, this may just work! Cygwin could define its own builtin_thread_pointer() to access its own cygtls areas from GCC, and if they are defined using storage class 'T', it should work. It is not clear if this is just intended as an optimization for a few embedded targets that have a dedicated pointer register for tls. -- Take care. Thanks, Brian Inglis Calgary, Alberta, Canada La perfection est atteinte Perfection is achieved non pas lorsqu'il n'y a plus rien à ajouter not when there is no more to add mais lorsqu'il n'y a plus rien à retrancher but when there is no more to cut -- Antoine de Saint-Exupéry -- Problem reports: https://cygwin.com/problems.html FAQ: https://cygwin.com/faq/ Documentation: https://cygwin.com/docs.html Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple