Changeset a165495


Ignore:
Timestamp:
Feb 7, 2026, 1:40:26 PM (9 hours ago)
Author:
Matthew Au-Yeung <mw2auyeu@…>
Branches:
stuck-waitfor-destruct
Children:
c7d106a
Parents:
3151bc09
git-author:
Matthew Au-Yeung <mw2auyeu@…> (01/27/26 19:12:37)
git-committer:
Matthew Au-Yeung <mw2auyeu@…> (02/07/26 13:40:26)
Message:

Make generated thread destructor link once instead of inline

  • waitfor context switch depends on fn pointers which will differ inline
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Validate/Autogen.cpp

    r3151bc09 ra165495  
    401401                add_qualifiers( dst->type, ast::CV::Qualifiers( ast::CV::Mutex ) );
    402402        }
    403         return genProto( "^?{}", { dst }, {} );
     403
     404        ast::FunctionDecl * decl = genProto( "^?{}", { dst }, {} );
     405        // For concurrent types, remove static storage and inline specifier, and add
     406        // cfa_linkonce attribute so the destructor has external linkage with linkonce
     407        // semantics. This is required for waitfor to work correctly across translation
     408        // units - the function pointer must be the same everywhere, and cfa_linkonce
     409        // ensures only one definition survives linking.
     410        if ( isConcurrentType() ) {
     411                auto mut = ast::mutate( decl );
     412                mut->storage = ast::Storage::Classes();
     413                mut->funcSpec = ast::Function::Specs();
     414                mut->attributes.push_back( new ast::Attribute( "cfa_linkonce" ) );
     415        }
     416        return decl;
    404417}
    405418
Note: See TracChangeset for help on using the changeset viewer.