o
    uJAf                     @  s  d dl mZ d dlZd dlZd dlZd dlZddlmZm	Z	 ddl
mZ ddlmZmZ ddlmZ ejrGdd	lmZ dd
lmZ ddlmZ G dd dZG dd dejdZejr`eZeZne ZZG dd deZG dd deeZG dd deeZG dd deeZG dd deZ G dd deeZ!G dd deZ"G dd  d eZ#G d!d" d"eZ$G d#d$ d$eZ%G d%d& d&eZ&G d'd( d(e&Z'G d)d* d*eeZ(G d+d, d,eZ)G d-d. d.e)Z*G d/d0 d0e)Z+dd8d9Z,dd;d<Z-dd>d?Z.G d@dA dAeZ/G dBdC dCeZ0G dDdE dEe/eZ1G dFdG dGe1Z2G dHdI dIe0e/eZ3G dJdK dKe3Z4G dLdM dMe3Z5G dNdO dOe3Z6G dPdQ dQe0e/eZ7G dRdS dSe0e/eZ8G dTdU dUeZ9G dVdW dWeZ:G dXdY dYeZ;G dZd[ d[eZ<G d\d] d]e<Z=G d^d_ d_e/eZ>G d`da dae>Z?G dbdc dce7Z@G ddde dee/eZAG dfdg dge/eZBeBZCG dhdi dieZDeDZEG djdk dkeZFG dldm dmeFeZGG dndo doeFeZHG dpdq dqeFeZIG drds dse/eZJG dtdu due/eZKG dvdw dweFeZLG dxdy dye/eZMG dzd{ d{eZNG d|d} d}eNZOG d~d deNZPdS )    )annotationsN   )ArLikeLinkerRSPFileSyntax   )mesonlib)EnvironmentExceptionMesonExceptionCompilerArgs)KeyedOptionDictType)Environment)MachineChoicec                   @  s   e Zd ZU ded< dDddZdEdFddZdGddZdHddZdIddZdJddZ	dKddZ
dLd d!ZdId"d#ZdMd+d,ZdNd-d.ZdId/d0ZdHd1d2ZedOd3d4ZedOd5d6ZdPd9d:ZdQd;d<ZdId=d>ZdId?d@ZdRdBdCZdS )SStaticLinkerstridexelistT.List[str]c                 C  
   || _ d S N)r   selfr    r   ?/usr/lib/python3.10/site-packages/mesonbuild/linkers/linkers.py__init__$      
zStaticLinker.__init__NargsT.Optional[T.Iterable[str]]returnr   c                 C  s
   t | |S r   r
   r   r   r   r   r   compiler_args'   r   zStaticLinker.compiler_argsboolc                 C     t  S )z[
        Determines whether the linker can accept arguments using the @rsp syntax.
        r   
is_windowsr   r   r   r   can_linker_accept_rsp*   s   z"StaticLinker.can_linker_accept_rspoptions'KeyedOptionDictType'c                 C     g S )z=Like compilers.get_base_link_args, but for the static linker.r   r   r'   r   r   r   get_base_link_args0      zStaticLinker.get_base_link_argsc                 C  
   | j  S r   r   copyr%   r   r   r   get_exelist4   r   zStaticLinker.get_exelistenv'Environment'is_thinc                 C  r)   r   r   r   r1   r3   r   r   r   get_std_link_args7      zStaticLinker.get_std_link_args	buildtypec                 C  r)   r   r   r   r7   r   r   r   get_buildtype_linker_args:   r6   z&StaticLinker.get_buildtype_linker_argstargetc                 C  r)   r   r   r   r:   r   r   r   get_output_args=   r6   zStaticLinker.get_output_argsc                 C  r)   r   r   r%   r   r   r   get_coverage_link_args@   r6   z#StaticLinker.get_coverage_link_args	build_dirfrom_dirrpath_pathsT.Tuple[str, ...]build_rpathinstall_rpath"T.Tuple[T.List[str], T.Set[bytes]]c                 C  
   g t  fS r   setr   r1   r>   r?   r@   rB   rC   r   r   r   build_rpath_argsC      
zStaticLinker.build_rpath_argsc                 C  r)   r   r   r   r1   r   r   r   thread_link_flagsH   r6   zStaticLinker.thread_link_flagsc                 C  r)   r   r   r%   r   r   r   openmp_flagsK   r6   zStaticLinker.openmp_flagsc                 C  r)   r   r   r*   r   r   r   get_option_link_argsN   r6   z!StaticLinker.get_option_link_argsc                 C     |d d  S r   r   clsr   r   r   r   unix_args_to_nativeQ      z StaticLinker.unix_args_to_nativec                 C  rO   r   r   rP   r   r   r   native_args_to_unixU   rS   z StaticLinker.native_args_to_unix
targetfileT.Optional[str]c                 C     d S r   r   r   rU   r   r   r   get_link_debugfile_nameY   r6   z$StaticLinker.get_link_debugfile_namec                 C  r)   r   r   rX   r   r   r   get_link_debugfile_args\   r,   z$StaticLinker.get_link_debugfile_argsc                 C  r)   r   r   r%   r   r   r   get_always_args`   r6   zStaticLinker.get_always_argsc                 C  r)   r   r   r%   r   r   r   get_linker_always_argsc   r6   z#StaticLinker.get_linker_always_argsr   c                 C  s(   |   rJ | j dt| j d)The format of the RSP file that this compiler supports.

        If `self.can_linker_accept_rsp()` returns True, then this needs to
        be implemented
        zI linker accepts RSP, but doesn' provide a supported format, this is a bugz8 does not implement rsp format, this shouldn't be called)r&   r   r   r%   r   r   r   rsp_file_syntaxf   s   zStaticLinker.rsp_file_syntaxr   r   r   )r   r   r   r   r   r!   r'   r(   r   r   r   r   r1   r2   r3   r!   r   r   r7   r   r   r   r:   r   r   r   r1   r2   r>   r   r?   r   r@   rA   rB   r   rC   r   r   rD   r1   r2   r   r   r   r   r   r   rU   r   r   rV   rU   r   r   r   r   r   )__name__
__module____qualname____annotations__r   r    r&   r+   r0   r5   r9   r<   r=   rI   rL   rM   rN   classmethodrR   rT   rY   rZ   r[   r\   r^   r   r   r   r   r       s0   
 















r   c                   @  s  e Zd ZU dZg g g g g g dZded< ejdddZdddZ	dddddZ
dddZdddZdddZdddZdd!d"Zdd$d%Zdd&d'Zdd(d)Zdd,d-Zdd2d3Zdd6d7Zdd8d9Zdd:d;Zdd<d=Zdd>d?Zdd@dAZddCdDZddFdGZddIdJZddKdLZddMdNZddOdPZ ej!ddRdSZ"ddTdUZ#ej!ddWdXZ$ddYdZZ%dd\d]Z&dd^d_Z'dd`daZ(ddbdcZ)ddddeZ*ddfdgZ+ddhdiZ,ddqdrZ-ddydzZ.dd|d}Z/dd~dZ0dS )DynamicLinkerzBase class for dynamic linkers.plaindebugdebugoptimizedreleaseminsizecustomT.Dict[str, T.List[str]]_BUILDTYPE_ARGSr   r   c                 C  rW   r   r   r%   r   r   r   r   }   r,   zDynamicLinker.idargT.Union[str, T.List[str]]r   c                   sb   t |tr|gn|} jd u r|S t  jtr  fdd|D S g }|D ]
}| j|g 7 }q$|S )Nc                   s   g | ]} j | qS r   )
prefix_arg).0r{   r%   r   r   
<listcomp>       z/DynamicLinker._apply_prefix.<locals>.<listcomp>)
isinstancer   r}   )r   r{   r   retr   r%   r   _apply_prefix   s   
zDynamicLinker._apply_prefixunknown versionversionr   for_machinemesonlib.MachineChoicer}   always_argsr   c                C  s(   || _ || _|| _|| _|| _d | _d S r   )r   r   r   r}   r   machine)r   r   r   r}   r   r   r   r   r   r      s   
zDynamicLinker.__init__c                 C  s   d t| j| jd| jS )Nz<{}: v{} `{}`> )formattyperl   r   joinr   r%   r   r   r   __repr__      zDynamicLinker.__repr__c                 C     | j S r   )r   r%   r   r   r   get_id      zDynamicLinker.get_idc                 C  s   d| j  d| j dS )N(r   ))r   r   r%   r   r   r   get_version_string      z DynamicLinker.get_version_stringc                 C  r-   r   r.   r%   r   r   r   r0      r   zDynamicLinker.get_exelistr!   c                 C  r"   r   r#   r%   r   r   r   get_accepts_rsp   s   zDynamicLinker.get_accepts_rspr   c                 C     t jS )r]   r   GCCr%   r   r   r   r^      s   zDynamicLinker.rsp_file_syntaxc                 C  r-   r   r   r/   r%   r   r   r   r[      r   zDynamicLinker.get_always_argsc                 C     dS N r   r%   r   r   r   get_lib_prefix   r6   zDynamicLinker.get_lib_prefixr'   r(   c                 C  r)   r   r   r*   r   r   r   get_option_args   r6   zDynamicLinker.get_option_argsr   r1   r2   T.Tuple[bool, bool]c                 C     t d| j d)Nz	Language z+ does not support has_multi_link_arguments.r   r   )r   r   r1   r   r   r   has_multi_arguments      z!DynamicLinker.has_multi_argumentsrU   rV   c                 C  r   )z*Name of debug file written out (see below)Nr   rX   r   r   r   get_debugfile_name   r,   z DynamicLinker.get_debugfile_namec                 C  r)   )zSome compilers (MSVC) write debug into a separate file.

        This method takes the target object path and returns a list of
        commands to append to the linker invocation to control where that
        file is written.
        r   rX   r   r   r   get_debugfile_args   s   z DynamicLinker.get_debugfile_argsc                 C  r)   r   r   r%   r   r   r   get_std_shared_lib_args   r6   z%DynamicLinker.get_std_shared_lib_argsc                 C  s   |   S r   )r   r*   r   r   r   get_std_shared_module_args      z(DynamicLinker.get_std_shared_module_argsc                 C  r   )NLinker z1 does not support position-independent executabler   r%   r   r   r   get_pie_args   s   zDynamicLinker.get_pie_argsc                 C  r)   r   r   r%   r   r   r   get_lto_args   r6   zDynamicLinker.get_lto_argspathc                 C  r)   r   r   r   r   r   r   r   get_thinlto_cache_args   r6   z$DynamicLinker.get_thinlto_cache_argsvaluec                 C  r)   r   r   r   r   r   r   r   sanitizer_args   r6   zDynamicLinker.sanitizer_argsr7   c                 C  s
   | j | S r   )rz   r8   r   r   r   get_buildtype_args   rJ   z DynamicLinker.get_buildtype_argsc                 C  r)   r   r   r%   r   r   r   get_asneeded_args   r6   zDynamicLinker.get_asneeded_argsc                 C  r   )Nr   z does not support link_wholer   r   r   r   r   get_link_whole_for      z DynamicLinker.get_link_whole_forc                 C  r   )Nr   z! does not support allow undefinedr   r%   r   r   r   get_allow_undefined_args   r   z&DynamicLinker.get_allow_undefined_args
outputnamec                 C  rW   r   r   r   r   r   r   r   r<      r,   zDynamicLinker.get_output_argsc                 C  r   )Nr   z, doesn't implement coverage data generation.r   r%   r   r   r   get_coverage_args   r   zDynamicLinker.get_coverage_argsdirnamec                 C  rW   r   r   r   r   r   r   r   get_search_args   r,   zDynamicLinker.get_search_argsc                 C  r)   r   r   rK   r   r   r   export_dynamic_args   r6   z!DynamicLinker.export_dynamic_args
implibnamec                 C  r)   )zThe name of the outputted import library.

        This implementation is used only on Windows by compilers that use GNU ld
        r   r   r   r   r   r   import_library_args   s   z!DynamicLinker.import_library_argsc                 C  r)   r   r   rK   r   r   r   thread_flags  r6   zDynamicLinker.thread_flagsc                 C  r)   )a  Arguments to error if there are any undefined symbols at link time.

        This is the inverse of get_allow_undefined_args().

        TODO: A future cleanup might merge this and
              get_allow_undefined_args() into a single method taking a
              boolean
        r   r%   r   r   r   no_undefined_args     	zDynamicLinker.no_undefined_argsc                 C  r)   )z&Arguments to make all warnings errors.r   r%   r   r   r   fatal_warnings  r,   zDynamicLinker.fatal_warningsc                 C  r)   r   r   r%   r   r   r   headerpad_args  r,   zDynamicLinker.headerpad_argsc                 C  r)   r   r   r   r   r   r   get_win_subsystem_args  s   z$DynamicLinker.get_win_subsystem_argsc                 C     t d)Nz,This linker does not support bitcode bundlesr	   r%   r   r   r   bitcode_args  r   zDynamicLinker.bitcode_argsr>   r?   r@   rA   rB   rC   rD   c                 C  rE   r   rF   rH   r   r   r   rI   "  rJ   zDynamicLinker.build_rpath_argsprefix
shlib_namesuffix	soversiondarwin_versionsT.Tuple[str, str]c                 C  r)   r   r   r   r1   r   r   r   r   r   r   r   r   get_soname_args'  r,   zDynamicLinker.get_soname_argsfilenamec                 C  s   t  S r   )r   r   r   r   r   r   get_archive_name+  s   zDynamicLinker.get_archive_namec                 C  r)   r   r   r%   r   r   r   get_command_to_archive_shlib/  r,   z*DynamicLinker.get_command_to_archive_shlibNr   r   r{   r|   r   r   
r   r   r   r   r}   r|   r   r   r   r   rb   r`   rk   ra   )r   r   r1   r2   r   r   ri   rj   r   r   r   r   r   r   r   r   rd   rh   r   r   r   r   r   r   r   r   rg   r   r   r   r   rf   r1   r2   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   )1rl   rm   rn   __doc__rz   ro   abcabstractpropertyr   r   r   r   r   r   r0   r   r^   r[   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   abstractmethodr<   r   r   r   r   r   r   r   r   r   r   rI   r   r   r   r   r   r   r   rq   p   sj   
 	














	




















rq   )	metaclassc                   @  s`   e Zd ZdgZdddZddd	Zdd
dZdddZedddZ	edddZ
dddZdS )VisualStudioLikeLinkerz/NOLOGOr   r   c                 C  r   r   r   )r   r   r   r   r   r   >  r   zVisualStudioLikeLinker.__init__r   r   c                 C  r-   r   r   r%   r   r   r   r[   A  r   z&VisualStudioLikeLinker.get_always_argsc                 C  r-   r   r   r%   r   r   r   r\   D  r   z-VisualStudioLikeLinker.get_linker_always_argsr:   c                 C  s,   g }| j r|d| j  g7 }|d| g7 }|S Nz	/MACHINE:/OUT:r   )r   r:   r   r   r   r   r<   G  s
   z&VisualStudioLikeLinker.get_output_argsr   c                 C     ddl m} ||S Nr   )VisualStudioCCompiler)compilers.cr   rR   rQ   r   r   r   r   r   rR   N     
z*VisualStudioLikeLinker.unix_args_to_nativec                 C  r   r   )r   r   rT   r   r   r   r   rT   S  r   z*VisualStudioLikeLinker.native_args_to_unixr   c                 C  r   r   r   MSVCr%   r   r   r   r^   X  r   z&VisualStudioLikeLinker.rsp_file_syntaxN)r   r   rb   re   rh   rk   )rl   rm   rn   r   r   r[   r\   r<   rp   rR   rT   r^   r   r   r   r   r   ;  s    



r   c                   @     e Zd ZdZdZd
ddZd	S )VisualStudioLinkerzMicrosoft's lib static linker.libr   r   r   r   c                 C     t | | t| | d S r   r   r   r   r   r   r   r   r   r   r   b     zVisualStudioLinker.__init__Nr   r   r   r   rl   rm   rn   r   r   r   r   r   r   r   r   \      r   c                   @  r   )IntelVisualStudioLinkerzIntel's xilib static linker.xilibr   r   r   r   c                 C  r   r   r   r   r   r   r   r   m  r   z IntelVisualStudioLinker.__init__Nr   r   r   r   r   r   r   g  r   r   c                      s6   e Zd ZdZd fddZdd
dZdddZ  ZS )ArLinkerarr   r   r   r   c                   sn   t  | t| jdg d }d}d}d|v r|d7 }d|v r#d}|g| _|| g| _d	|v | _|| _d S )
Nz-hr   Zcsrr   z[D]Dz[T]Tz@<)	superr   r   
Popen_safer   std_argsstd_thin_argscan_rspr   )r   r   r   stdoZstdargsZthinargs	__class__r   r   r   u  s   

zArLinker.__init__r   r!   c                 C  r   r   )r  r%   r   r   r   r&     r   zArLinker.can_linker_accept_rspr1   r2   r3   c                 C  s0   |r|j | j  s|j | j  s| jS | jS r   )machinesr   	is_darwinis_sunosr  r  r4   r   r   r   r5     s
   zArLinker.get_std_link_args)r   r   r   r   r`   rc   )rl   rm   rn   r   r   r&   r5   __classcell__r   r   r
  r   r   r  s
    
r   c                   @     e Zd ZdZdS )AppleArLinkerZapplearNrl   rm   rn   r   r   r   r   r   r    s    r  c                   @  r  )ArmarLinkerarmarNr  r   r   r   r   r        r  c                      sN   e Zd Zejdd fdd	ZdddZdddZdddZdddZ	  Z
S )DLinker)
rsp_syntaxr   r   archr   r  r   c                  s&   t  | |d | _|| _|| _d S )Nr   )r  r   r   r  _DLinker__rsp_syntax)r   r   r  r  r
  r   r   r     s   

zDLinker.__init__r1   r2   r3   r!   r   c                 C     dgS )Nz-libr   r4   r   r   r   r5     r   zDLinker.get_std_link_argsr:   c                 C  
   d| gS )Nz-of=r   r;   r   r   r   r<     r   zDLinker.get_output_argsc                 C  s<   t  r| jdkrdgS | jdkr| jdkrdgS dgS g S )Nx86_64z-m64
x86_mscoffdmdz
-m32mscoffz-m32)r   r$   r  r   r%   r   r   r   r\     s   
zDLinker.get_linker_always_argsc                 C  r   r   )r  r%   r   r   r   r^     r   zDLinker.rsp_file_syntax)r   r   r  r   r  r   rc   re   rb   rk   )rl   rm   rn   r   r   r   r5   r<   r\   r^   r  r   r   r
  r   r    s    


	r  c                      <   e Zd Zd fddZdddZdddZdddZ  ZS )
CcrxLinkerr   r   c                      t  | d| _d S )Nrlinkr  r   r   r   r
  r   r   r        
zCcrxLinker.__init__r   r!   c                 C  r   NFr   r%   r   r   r   r&     r6   z CcrxLinker.can_linker_accept_rspr:   r   c                 C     d| gS Nz-output=r   r;   r   r   r   r<        zCcrxLinker.get_output_argsc                 C     ddgS )Nz-nologoz-form=libraryr   r%   r   r   r   r\     r   z!CcrxLinker.get_linker_always_argsr_   r`   re   rb   rl   rm   rn   r   r&   r<   r\   r  r   r   r
  r   r     
    

r   c                      r  )
Xc16Linkerr   r   c                   r!  )Nzxc16-arr#  r   r
  r   r   r     r$  zXc16Linker.__init__r   r!   c                 C  r   r%  r   r%   r   r   r   r&     r6   z Xc16Linker.can_linker_accept_rspr:   r   c                 C     | gS r   r   r;   r   r   r   r<     r   zXc16Linker.get_output_argsc                 C  r  )NZrcsr   r%   r   r   r   r\     r   z!Xc16Linker.get_linker_always_argsr_   r`   re   rb   r*  r   r   r
  r   r,    r+  r,  c                      s2   e Zd Zd fddZdddZdddZ  ZS )CompCertLinkerr   r   c                   r!  )Nccompr#  r   r
  r   r   r     r$  zCompCertLinker.__init__r   r!   c                 C  r   r%  r   r%   r   r   r   r&     r6   z$CompCertLinker.can_linker_accept_rspr:   r   c                 C  r&  Nz-or   r;   r   r   r   r<     r(  zCompCertLinker.get_output_argsr_   r`   re   )rl   rm   rn   r   r&   r<   r  r   r   r
  r   r.    s    
r.  c                      r  )TILinkerr   r   c                   r!  )Nzti-arr#  r   r
  r   r   r     r$  zTILinker.__init__r   r!   c                 C  r   r%  r   r%   r   r   r   r&     r6   zTILinker.can_linker_accept_rspr:   r   c                 C  r-  r   r   r;   r   r   r   r<     r   zTILinker.get_output_argsc                 C  r  )N-rr   r%   r   r   r   r\     r   zTILinker.get_linker_always_argsr_   r`   re   rb   r*  r   r   r
  r   r1    r+  r1  c                   @  r  )C2000Linkerar2000Nr  r   r   r   r   r3        r3  c                   @  s   e Zd ZdZddgZdS )AIXArLinkerZaixarz-csrz-XanyN)rl   rm   rn   r   r  r   r   r   r   r6    s    r6  c                   @  s4   e Zd ZdddZdddZdd
dZdddZdS )MetrowerksStaticLinkerr   r!   c                 C  r   NTr   r%   r   r   r   r&      r6   z,MetrowerksStaticLinker.can_linker_accept_rspr   c                 C  r  )Nz-libraryr   r%   r   r   r   r\     r   z-MetrowerksStaticLinker.get_linker_always_argsr:   r   c                 C     d|gS r0  r   r;   r   r   r   r<     r   z&MetrowerksStaticLinker.get_output_argsr   c                 C  r   r   r   r%   r   r   r   r^   	  r   z&MetrowerksStaticLinker.rsp_file_syntaxNr`   rb   re   rk   )rl   rm   rn   r&   r\   r<   r^   r   r   r   r   r7    s
    


r7  c                   @  r  )MetrowerksStaticLinkerARMmwldarmNr  r   r   r   r   r:    r  r:  c                   @  r  )%MetrowerksStaticLinkerEmbeddedPowerPCmwldeppcNr  r   r   r   r   r<    r  r<  
raw_rpathsrA   r>   r   r?   r   r   c                   s     fdd| D }t |}|S )Nc                   s   g | ]}t | qS r   )evaluate_rpathr~   pr>   r?   r   r   r     s    z"prepare_rpaths.<locals>.<listcomp>)order_rpaths)r>  r>   r?   Zinternal_format_rpathsZordered_rpathsr   rB  r   prepare_rpaths  s   rD  
rpath_listc                 C  s   t | tjjdS )N)key)sortedosr   isabs)rE  r   r   r   rC    s   	rC  rA  c                 C  s>   | |krdS t j| r| S t jt j|| t j||S r   )rH  r   rI  relpathr   )rA  r>   r?   r   r   r   r?  )  s
   "r?  c                   @  s.   e Zd ZdZdddZddd	ZdddZdS )PosixDynamicLinkerMixinzMixin class for POSIX-ish linkers.

    This is obviously a pretty small subset of the linker interface, but
    enough dynamic linkers that meson supports are POSIX-like but not
    GNU-like that it makes sense to split this out.
    r   r   r   r   c                 C  r9  r0  r   r   r   r   r   r<   ;  r   z'PosixDynamicLinkerMixin.get_output_argsc                 C  r  )N-sharedr   r%   r   r   r   r   >  r   z/PosixDynamicLinkerMixin.get_std_shared_lib_argsr   c                 C  r  Nz-Lr   r   r   r   r   r   A  r   z'PosixDynamicLinkerMixin.get_search_argsNr   rb   r   )rl   rm   rn   r   r<   r   r   r   r   r   r   rK  2  s
    

rK  c                
   @  s  e Zd ZU dZejrejZdMddZ	g g g dgg g d	Z
d
ed< dddddddddd	Zded< dNddZdOddZdOddZdPd!d"ZdOd#d$ZdOd%d&ZdQd(d)ZdOd*d+ZdRd.d/ZdSd1d2ZdRd3d4ZdOd5d6ZdOd7d8ZdTd?d@ZdUdHdIZdQdJdKZdLS )VGnuLikeDynamicLinkerMixinzMixin class for dynamic linkers that provides gnu-like interface.

    This acts as a base for the GNU linkers (bfd and gold), LLVM's lld, and
    other linkers like GNU-ld.
    r{   r|   r   r   c                 C  rW   r   r   r   r{   r   r   r   r   O      z'GnuLikeDynamicLinkerMixin._apply_prefixz-O1rr   ry   rz   1windowsconsole71011121316)	nativerR  rS  posixZefi_applicationZefi_boot_service_driverZefi_runtime_driverZefi_romZboot_applicationzT.Dict[str, str]_SUBSYSTEMSr7   r   c                      t  fdd j| D S )Nc                      g | ]}  |qS r   r   r~   ar%   r   r   r   i  r   z@GnuLikeDynamicLinkerMixin.get_buildtype_args.<locals>.<listcomp>r   listifyrz   r8   r   r%   r   r   f  s   z,GnuLikeDynamicLinkerMixin.get_buildtype_argsc                 C  r  )Nz-pier   r%   r   r   r   r   k  r   z&GnuLikeDynamicLinkerMixin.get_pie_argsc                 C  
   |  dS )Nz--as-neededr_  r%   r   r   r   r   n  r   z+GnuLikeDynamicLinkerMixin.get_asneeded_argsr   c                 C      |s|S |  d| |  d S Nz--whole-archivez--no-whole-archiver_  r   r   r   r   r   q     z,GnuLikeDynamicLinkerMixin.get_link_whole_forc                 C  rd  N--allow-shlib-undefinedr_  r%   r   r   r   r   v  r   z2GnuLikeDynamicLinkerMixin.get_allow_undefined_argsc                 C  r  )Nz-fltor   r%   r   r   r   r   y  r   z&GnuLikeDynamicLinkerMixin.get_lto_argsr   c                 C     |dkrg S d| gS Nnonez-fsanitize=r   r   r   r   r   r   |     
z(GnuLikeDynamicLinkerMixin.sanitizer_argsc                 C  r  Nz
--coverager   r%   r   r   r   r     r   z+GnuLikeDynamicLinkerMixin.get_coverage_argsr1   r2   c                 C  s0   |j | j }| s| r| dS | dS )Nz--export-all-symbolsz-export-dynamicr  r   r$   	is_cygwinr   )r   r1   mr   r   r   r     s   

z-GnuLikeDynamicLinkerMixin.export_dynamic_argsr   c                 C     |  d| S )Nz--out-implib=r_  r   r   r   r   r        z-GnuLikeDynamicLinkerMixin.import_library_argsc                 C  s   |j | j  r
g S dgS Nz-pthread)r  r   is_haikurK   r   r   r   r     s   z&GnuLikeDynamicLinkerMixin.thread_flagsc                 C  rd  )Nz--no-undefinedr_  r%   r   r   r   r     r   z+GnuLikeDynamicLinkerMixin.no_undefined_argsc                 C  rd  )Nz--fatal-warningsr_  r%   r   r   r   r     r   z(GnuLikeDynamicLinkerMixin.fatal_warningsr   r   r   r   r   r   c           	      C  sR   |j | j }| s| rg S |d u rdnd| }| d| | d| | S Nr   .z-soname,ro  )	r   r1   r   r   r   r   r   rq  sostrr   r   r   r     s
   z)GnuLikeDynamicLinkerMixin.get_soname_argsr>   r?   r@   rA   rB   rC   rD   c              
     sr  |j | j }| s| rg t fS |s|s|sg t fS g }d t|||}	t fdd|	D }
t }|
D ]
}||	d q9|dkr]|
| |
dD ]
}||	d qRt set rm|| d d|
}t|t|k rdt|t|  }|s|}n|d | }|| d	|  t r||fS |D ]}|| d
tj||  q||fS )N$ORIGINc                      g | ]	}t j |qS r   rH  r   r   r@  Zorigin_placeholderr   r   r         z>GnuLikeDynamicLinkerMixin.build_rpath_args.<locals>.<listcomp>utf8r   :z	-z,originX-rpath,z-rpath-link,)r  r   r$   rp  rG   rD  r   
OrderedSetaddencodesplitis_dragonflybsd
is_openbsdextendr   r   lenr  rH  r   )r   r1   r>   r?   r@   rB   rC   rq  r   processed_rpaths	all_pathsrpath_dirs_to_removerA  pathspaddingr   r|  r   rI     s<   



 z*GnuLikeDynamicLinkerMixin.build_rpath_argsc                 C  sp   d }d|v r| dd\}}| j|}|d ur*|d ur#|d| 7 }d| g}n	td|d| |S )N,r   r  --subsystem,win_subsystem: z: not handled in MinGW linker. This should not be possible.)r  r\  getr   MesonBugExceptionr   )r   r   Zversionsuffixnewvaluer   r   r   r   r     s   
z0GnuLikeDynamicLinkerMixin.get_win_subsystem_argsNr   rd   rb   rh   r   rg   r   r   rf   )rl   rm   rn   r   r  TYPE_CHECKINGr   HOSTr   r   rz   ro   r\  r   r   r   r   r   r   r   r   r   r   r   r   r   r   rI   r   r   r   r   r   rN  E  sL   
 
















	DrN  c                   @  s   e Zd ZdZdZd7ddZd7ddZd8ddZd7ddZd9ddZ	d7ddZ
d:ddZd7ddZd7ddZd7ddZd7ddZd;d(d)Zd<d1d2Zd=d4d5Zd6S )>AppleDynamicLinkerzApple's ld implementation.Zld64r   r   c                 C  rd  )Nz-dead_strip_dylibsr_  r%   r   r   r   r     r   z$AppleDynamicLinker.get_asneeded_argsc                 C  rd  )N-undefined,dynamic_lookupr_  r%   r   r   r   r     r   z+AppleDynamicLinker.get_allow_undefined_argsr'   r(   c                 C  s   dg|  d S )Nz-bundler  r_  r*   r   r   r   r     s   z-AppleDynamicLinker.get_std_shared_module_argsc                 C  r)   r   r   r%   r   r   r   r     r6   zAppleDynamicLinker.get_pie_argsr   c                 C  s,   g }|D ]}| | d || q|S )Nz-force_load)r  r   append)r   r   resultra  r   r   r   r     s
   z%AppleDynamicLinker.get_link_whole_forc                 C  r  rn  r   r%   r   r   r   r     r   z$AppleDynamicLinker.get_coverage_argsr   r   c                 C  rj  rk  r   r   r   r   r   r     rm  z!AppleDynamicLinker.sanitizer_argsc                 C  r)   r   r   r%   r   r   r   r     r   z$AppleDynamicLinker.no_undefined_argsc                 C  rd  )Nz-headerpad_max_install_namesr_  r%   r   r   r   r   %  r   z!AppleDynamicLinker.headerpad_argsc                 C  rd  )Nz-bitcode_bundler_  r%   r   r   r   r   (  r   zAppleDynamicLinker.bitcode_argsc                 C  rd  )Nz-fatal_warningsr_  r%   r   r   r   r   +  r   z!AppleDynamicLinker.fatal_warningsr1   r2   r   r   r   r   r   r   c           	      C  sZ   d||g}|d ur| d|  | d dd|g}|r+|d|d d|d	 g |S )
Nz@rpath/rw  z.dylibz-install_namer   z-compatibility_versionr   z-current_versionr   )r  r   r  )	r   r1   r   r   r   r   r   Zinstall_namer   r   r   r   r   .  s   

z"AppleDynamicLinker.get_soname_argsr>   r?   r@   rA   rB   rC   rD   c                   |   |s|s|sg t  fS g }d t|||}t fdd|D }	|dkr*|	| |	D ]}
|| d|
  q,|t  fS )Nz@loader_pathc                   rz  r   r{  r@  r|  r   r   r   D  r}  z7AppleDynamicLinker.build_rpath_args.<locals>.<listcomp>r   r  rG   rD  r   r  r  r  r   r   r1   r>   r?   r@   rB   rC   r   r  r  rpr   r|  r   rI   :  s   


z#AppleDynamicLinker.build_rpath_argsr   c                 C  r  )Nz-Wl,-cache_path_lto,r   r   r   r   r   r   L  r   z)AppleDynamicLinker.get_thinlto_cache_argsNrb   ra   rh   r   r   rf   r   )rl   rm   rn   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rI   r   r   r   r   r   r    s"    












r  c                   @  r  )LLVMLD64DynamicLinkerzld64.lldNr  r   r   r   r   r  P  r5  r  c                   @  s   e Zd ZdZdddZdS )GnuDynamicLinkerz)Representation of GNU ld.bfd and ld.gold.r   r!   c                 C  r   r8  r   r%   r   r   r   r   Y  r6   z GnuDynamicLinker.get_accepts_rspNr`   )rl   rm   rn   r   r   r   r   r   r   r  U      r  c                   @     e Zd ZdZd	ddZdS )
GnuGoldDynamicLinkerzld.goldr   r   r   r   c                 C  r  )Nz-Wl,-plugin-opt,cache-dir=r   r   r   r   r   r   a  r   z+GnuGoldDynamicLinker.get_thinlto_cache_argsNr   rl   rm   rn   r   r   r   r   r   r   r  ]  r  r  c                   @  r  )GnuBFDDynamicLinkerzld.bfdNr  r   r   r   r   r  e  r5  r  c                   @  r  )
MoldDynamicLinkerzld.moldr   r   r   r   c                 C  r  Nz-Wl,--thinlto-cache-dir=r   r   r   r   r   r   n  r   z(MoldDynamicLinker.get_thinlto_cache_argsNr   r  r   r   r   r   r  j  r  r  c                      sJ   e Zd ZdZdZddd fddZdddZdddZdddZ  Z	S )LLVMDynamicLinkerzRepresentation of LLVM's ld.lld linker.

    This is only the gnu-like linker, not the apple like or link.exe like
    linkers.
    zld.lldr   r   r   r   r   r   r}   r|   r   r   r   c                  sL   t  j|||||d t| j| | d \}}}d|vo"d|v| _d S )Nr   ri  z)unknown argument: --allow-shlib-undefinedz+unknown argument: '--allow-shlib-undefined')r  r   r   r  r   r   has_allow_shlib_undefined)r   r   r   r}   r   r   _er
  r   r   r   |  s    zLLVMDynamicLinker.__init__r   c                 C  s   | j r| dS g S rh  )r  r   r%   r   r   r   r     s   
z*LLVMDynamicLinker.get_allow_undefined_argsr   c                 C  r  r  r   r   r   r   r   r     r   z(LLVMDynamicLinker.get_thinlto_cache_argsr   c                 C  s`   d }d|v r| dd\}}|| jv r'|d ur|d| 7 }| d| gS td| d)Nr  r   r  r  r  z8 not handled in lld linker. This should not be possible.)r  r\  r   r   r  )r   r   r   r   r   r   r     s   
z(LLVMDynamicLinker.get_win_subsystem_argsr   rb   r   r   )
rl   rm   rn   r   r   r   r   r   r   r  r   r   r
  r   r  r  s    


r  c                   @  sF   e Zd ZdZdZd ddZd ddZd!ddZd ddZd"ddZ	dS )#WASMDynamicLinkerzEmscripten's wasm-ld.zld.wasmr   r   c                 C  r  )Nz-sERROR_ON_UNDEFINED_SYMBOLS=0r   r%   r   r   r   r     r   z*WASMDynamicLinker.get_allow_undefined_argsc                 C  r  )Nz-sERROR_ON_UNDEFINED_SYMBOLS=1r   r%   r   r   r   r     r   z#WASMDynamicLinker.no_undefined_argsr1   r2   r   r   r   r   r   r   r   c                 C     t | j dNz# does not support shared libraries.r	   r   r   r   r   r   r        z!WASMDynamicLinker.get_soname_argsc                 C  r)   r   r   r%   r   r   r   r     r6   z#WASMDynamicLinker.get_asneeded_argsr>   r?   r@   rA   rB   rC   rD   c                 C  rE   r   rF   rH   r   r   r   rI     rJ   z"WASMDynamicLinker.build_rpath_argsNrb   r   rf   )
rl   rm   rn   r   r   r   r   r   r   rI   r   r   r   r   r    s    



r  c                      sr   e Zd ZdZdZddd' fd	d
Zd(ddZd)ddZd*ddZd+ddZ	d,ddZ
d*ddZd-d%d&Z  ZS ).CcrxDynamicLinkerz!Linker for Renesas CCrx compiler.r"  r   r   r   r   r   r   c                     t  jdg|dg |d d S )Nz	rlink.exer   r   r  r   r   r   r   r
  r   r   r        
zCcrxDynamicLinker.__init__r   r!   c                 C  r   r%  r   r%   r   r   r   r     r6   z!CcrxDynamicLinker.get_accepts_rspc                 C  r   )Nz-lib=r   r%   r   r   r   r     r6   z CcrxDynamicLinker.get_lib_prefixr   c                 C  r)   r   r   r%   r   r   r   r     r6   z)CcrxDynamicLinker.get_std_shared_lib_argsr   c                 C  r&  r'  r   r   r   r   r   r<     r(  z!CcrxDynamicLinker.get_output_argsr   'T.NoReturn'c                 C  r   )Nz-rlink.exe does not have a search dir argumentOSErrorr   r   r   r   r     r   z!CcrxDynamicLinker.get_search_argsc                 C  r)   r   r   r%   r   r   r   r     r6   z*CcrxDynamicLinker.get_allow_undefined_argsr1   r2   r   r   r   r   r   r   c                 C  r)   r   r   r   r   r   r   r     r,   z!CcrxDynamicLinker.get_soname_argsr   r   r   r   r`   r   rb   r   r   r   r   r  r   )rl   rm   rn   r   r   r   r   r   r   r<   r   r   r   r  r   r   r
  r   r    s    





r  c                      s   e Zd ZdZdZddd3 fd	d
Zd4ddZd5ddZd6ddZd7ddZ	d8ddZ
d9ddZd7ddZd:d(d)Zd;d1d2Z  ZS )<Xc16DynamicLinkerz#Linker for Microchip XC16 compiler.xc16-gccr   r   r   r   r   r   c                  r  )Nr  r   r   r  r  r
  r   r   r     r  zXc16DynamicLinker.__init__r   r   r   c                 C  re  Nz--start-groupz--end-groupr_  r   r   r   r   r     rg  z$Xc16DynamicLinker.get_link_whole_forr!   c                 C  r   r%  r   r%   r   r   r   r     r6   z!Xc16DynamicLinker.get_accepts_rspc                 C  r   r   r   r%   r   r   r   r     r6   z Xc16DynamicLinker.get_lib_prefixc                 C  r)   r   r   r%   r   r   r   r     r6   z)Xc16DynamicLinker.get_std_shared_lib_argsr   c                 C  r&  r0  r   r   r   r   r   r<     r(  z!Xc16DynamicLinker.get_output_argsr   r  c                 C  r   )Nz,xc16-gcc does not have a search dir argumentr  r   r   r   r   r     r   z!Xc16DynamicLinker.get_search_argsc                 C  r)   r   r   r%   r   r   r   r     r6   z*Xc16DynamicLinker.get_allow_undefined_argsr1   r2   r   r   r   r   r   r   c                 C  r)   r   r   r   r   r   r   r     r,   z!Xc16DynamicLinker.get_soname_argsr>   r?   r@   rA   rB   rC   rD   c                 C  rE   r   rF   rH   r   r   r   rI     rJ   z"Xc16DynamicLinker.build_rpath_argsr  rh   r`   r   rb   r   r  r   rf   rl   rm   rn   r   r   r   r   r   r   r   r<   r   r   r   rI   r  r   r   r
  r   r        







r  c                      s   e Zd ZdZdZddd2 fd	d
Zd3ddZd4ddZd5ddZd6ddZ	d7ddZ
d8ddZd6ddZd9d'd(Zd:d0d1Z  ZS );CompCertDynamicLinkerzLinker for CompCert C compiler.r/  r   r   r   r   r   r   c                  r  )Nr/  r   r   r  r  r
  r   r   r     r  zCompCertDynamicLinker.__init__r   r   r   c                 C  re  )Nz-Wl,--whole-archivez-Wl,--no-whole-archiver_  r   r   r   r   r     rg  z(CompCertDynamicLinker.get_link_whole_forr!   c                 C  r   r%  r   r%   r   r   r   r     r6   z%CompCertDynamicLinker.get_accepts_rspc                 C  r   r   r   r%   r   r   r   r     r6   z$CompCertDynamicLinker.get_lib_prefixc                 C  r)   r   r   r%   r   r   r   r     r6   z-CompCertDynamicLinker.get_std_shared_lib_argsr   c                 C  r&  r0  r   r   r   r   r   r<     r(  z%CompCertDynamicLinker.get_output_argsr   c                 C  r&  rM  r   r   r   r   r   r     r(  z%CompCertDynamicLinker.get_search_argsc                 C  r)   r   r   r%   r   r   r   r      r6   z.CompCertDynamicLinker.get_allow_undefined_argsr1   r2   r   r   r   r   r   r   c                 C  r  r  r  r   r   r   r   r   #  r  z%CompCertDynamicLinker.get_soname_argsr>   r?   r@   rA   rB   rC   rD   c                 C  rE   r   rF   rH   r   r   r   rI   '  rJ   z&CompCertDynamicLinker.build_rpath_argsr  rh   r`   r   rb   r   r   r   rf   r  r   r   r
  r   r    r  r  c                      s|   e Zd ZdZdZddd# fddZd$ddZd%ddZd&ddZd'ddZ	d(ddZ
d)ddZd'dd Zd'd!d"Z  ZS )*TIDynamicLinkerz-Linker for Texas Instruments compiler family.tir   r   r   r   r   r   r   r   c                     t  j||dg |d d S Nr   r   r  r   r   r   r   r
  r   r   r   2     
zTIDynamicLinker.__init__r   r   c                 C  re  r  r_  r   r   r   r   r   7  rg  z"TIDynamicLinker.get_link_whole_forr!   c                 C  r   r%  r   r%   r   r   r   r   <  r6   zTIDynamicLinker.get_accepts_rspc                 C  r   )Nz-l=r   r%   r   r   r   r   ?  r6   zTIDynamicLinker.get_lib_prefixc                 C  r)   r   r   r%   r   r   r   r   B  r6   z'TIDynamicLinker.get_std_shared_lib_argsr   c                 C  s   dd| gS )N-zz--output_file=r   r   r   r   r   r<   E  rs  zTIDynamicLinker.get_output_argsr   r  c                 C  r   )Nz.TI compilers do not have a search dir argumentr  r   r   r   r   r   H  r   zTIDynamicLinker.get_search_argsc                 C  r)   r   r   r%   r   r   r   r   K  r6   z(TIDynamicLinker.get_allow_undefined_argsc                 C  r)   r   r   r%   r   r   r   r[   N  r6   zTIDynamicLinker.get_always_argsr   r   r   r   r   r   rh   r`   r   rb   r   r  )rl   rm   rn   r   r   r   r   r   r   r   r<   r   r   r[   r  r   r   r
  r   r  ,  s    






r  c                   @  r  )C2000DynamicLinkercl2000Nr  r   r   r   r   r  R  r5  r  c                      sJ   e Zd ZdZdZddd fd	d
ZdddZdddZdddZ  Z	S )ArmDynamicLinkerzLinker for the ARM compiler.armlinkr   r   r   r   r   r   c                  r  )Nr  r   r   r  r  r
  r   r   r   ]  r  zArmDynamicLinker.__init__r   r!   c                 C  r   r%  r   r%   r   r   r   r   b  r6   z ArmDynamicLinker.get_accepts_rspr  c                 C  r   )Nz/The Arm Linkers do not support shared librariesr   r%   r   r   r   r   e  r   z(ArmDynamicLinker.get_std_shared_lib_argsr   c                 C  r)   r   r   r%   r   r   r   r   h  r6   z)ArmDynamicLinker.get_allow_undefined_argsr  r`   )r   r  rb   )
rl   rm   rn   r   r   r   r   r   r   r  r   r   r
  r   r  W  s    

r  c                   @  s$   e Zd ZdZdddZdd
dZdS )ArmClangDynamicLinkerzLinker used with ARM's clang fork.

    The interface is similar enough to the old ARM ld that it inherits and
    extends a few things as needed.
    r1   r2   r   r   c                 C  r  )Nz--export_dynamicr   rK   r   r   r   r   t  r   z)ArmClangDynamicLinker.export_dynamic_argsr   r   c                 C  r  )Nz
--symdefs=r   r   r   r   r   r   w  r   z)ArmClangDynamicLinker.import_library_argsNrg   r   )rl   rm   rn   r   r   r   r   r   r   r   r  l  s    
r  c                   @  s   e Zd ZdZdZdS )QualcommLLVMDynamicLinkerz-ARM Linker from Snapdragon LLVM ARM Compiler.zld.qcldN)rl   rm   rn   r   r   r   r   r   r   r  z  s    r  c                   @  s2   e Zd ZdZdZdddZdddZdddZdS )NAGDynamicLinkera;  NAG Fortran linker, ld via gcc indirection.

    Using nagfor -Wl,foo passes option foo to a backend gcc invocation.
    (This linking gathers the correct objects needed from the nagfor runtime
    system.)
    To pass gcc -Wl,foo options (i.e., to ld) one must apply indirection
    again: nagfor -Wl,-Wl,,foo
    Znagr1   r2   r>   r   r?   r@   rA   rB   rC   r   rD   c                   r  )Nry  c                   rz  r   r{  r@  r|  r   r   r     r}  z5NAGDynamicLinker.build_rpath_args.<locals>.<listcomp>r   z-Wl,-Wl,,-rpath,,r  r  r   r|  r   rI     s   


z!NAGDynamicLinker.build_rpath_argsr   c                 C  r)   r   r   r%   r   r   r   r     r6   z)NAGDynamicLinker.get_allow_undefined_argsc                 C  s   ddl m} || jdg S )Nr   )NAGFortranCompilerz-Wl,-shared)Zcompilers.fortranr  Zget_nagfor_quietr   )r   r  r   r   r   r     s   z(NAGDynamicLinker.get_std_shared_lib_argsNrf   rb   )rl   rm   rn   r   r   rI   r   r   r   r   r   r   r    s    	

r  c                   @  s<   e Zd ZdZdZdddZdddZdddZd ddZdS )!PGIDynamicLinkerzPGI linker.pgir   r   c                 C  r)   r   r   r%   r   r   r   r     r6   z)PGIDynamicLinker.get_allow_undefined_argsr1   r2   r   r   r   r   r   r   r   c                 C  r)   r   r   r   r   r   r   r     r,   z PGIDynamicLinker.get_soname_argsc                 C  s"   t  rddgS t  rdgS g S )Nz	-Bdynamicz	-MmakedllrL  )r   r$   is_linuxr%   r   r   r   r     s
   z(PGIDynamicLinker.get_std_shared_lib_argsr>   r?   r@   rA   rB   rC   rD   c                   s2   |j | j  s fdd|D t fS g t fS )Nc                   s   g | ]}d t j | qS )z-Rr{  r@  r>   r   r   r     s    z5PGIDynamicLinker.build_rpath_args.<locals>.<listcomp>)r  r   r$   rG   rH   r   r  r   rI     s   
z!PGIDynamicLinker.build_rpath_argsNrb   r   rf   )	rl   rm   rn   r   r   r   r   r   rI   r   r   r   r   r    s    


r  c                      s2   e Zd Zd fddZdd
dZdddZ  ZS )PGIStaticLinkerr   r   c                   s   t  | d| _dg| _d S )Nr  r2  )r  r   r   r  r   r
  r   r   r     s   zPGIStaticLinker.__init__r1   r2   r3   r!   r   c                 C  r   r   )r  r4   r   r   r   r5     r   z!PGIStaticLinker.get_std_link_argsr:   r   c                 C  s   |gS r   r   r;   r   r   r   r<     r   zPGIStaticLinker.get_output_argsr_   rc   re   )rl   rm   rn   r   r5   r<   r  r   r   r
  r   r    s    
r  c                      s   e Zd ZU dZejrejZdFddZ	g g g dgd	dgg d
Z
ded< dddddG fddZdHddZdId d!ZdJd#d$ZdK fd%d&ZdLd(d)ZdKd*d+ZdMd-d.ZdNd/d0ZdOd2d3ZdKd4d5ZdPd>d?ZdQdAdBZdRdDdEZ  ZS )SVisualStudioLikeLinkerMixinzCMixin class for dynamic linkers that act like Microsoft's link.exe.r{   r|   r   r   c                 C  rW   r   r   rO  r   r   r   r     rP  z)VisualStudioLikeLinkerMixin._apply_prefixz/OPT:REFz/INCREMENTAL:NOrr   ry   rz   r   Tx86)r   directr   r   r   r   r}   r   r   r   r  r!   r   c                  s&   t  j|||||d || _|| _d S )Nr   )r  r   r   r  )r   r   r   r}   r   r   r  r   r
  r   r   r     s   
z$VisualStudioLikeLinkerMixin.__init__r7   c                   r]  )Nc                   r^  r   r_  r`  r%   r   r   r     r   zBVisualStudioLikeLinkerMixin.get_buildtype_args.<locals>.<listcomp>rb  r8   r   r%   r   r     r   z.VisualStudioLikeLinkerMixin.get_buildtype_argsc                 C  s   | j  S r   )r  r%   r   r   r   invoked_by_compiler  r   z/VisualStudioLikeLinkerMixin.invoked_by_compilerr   c                 C  s   |  d| j d| gS r   )r   r   r   r   r   r   r<        z+VisualStudioLikeLinkerMixin.get_output_argsc                   s   t   }| d| S )Nz/nologo)r  r[   r   )r   parentr
  r   r   r[     s   
z+VisualStudioLikeLinkerMixin.get_always_argsr   c                 C  rr  )Nz	/LIBPATH:r_  r   r   r   r   r     rs  z+VisualStudioLikeLinkerMixin.get_search_argsc                 C  rd  )Nz/DLLr_  r%   r   r   r   r     r   z3VisualStudioLikeLinkerMixin.get_std_shared_lib_argsrU   c                 C     |S r   r   rX   r   r   r   r     r6   z.VisualStudioLikeLinkerMixin.get_debugfile_namec                 C  s   |  dd| | gS )Nz/DEBUGz/PDB:)r   r   rX   r   r   r   r     r  z.VisualStudioLikeLinkerMixin.get_debugfile_argsr   c                 C  s0   t |}g }|D ]}|| d|  q	|S )Nz/WHOLEARCHIVE:)r   rc  r  r   )r   r   lra  r   r   r   r     s
   
z.VisualStudioLikeLinkerMixin.get_link_whole_forc                 C  r)   r   r   r%   r   r   r   r     r6   z4VisualStudioLikeLinkerMixin.get_allow_undefined_argsr1   r2   r   r   r   r   r   r   c                 C  r)   r   r   r   r   r   r   r     r,   z+VisualStudioLikeLinkerMixin.get_soname_argsr   c                 C  s   |  d| gS )z+The command to generate the import library.z/IMPLIB:r_  r   r   r   r   r     r  z/VisualStudioLikeLinkerMixin.import_library_argsr   c                 C  r   r   r   r%   r   r   r   r^     r   z+VisualStudioLikeLinkerMixin.rsp_file_syntaxr   )r   r   r   r   r}   r|   r   r   r   r   r  r!   r   r   rd   r`   r   rb   r   )rU   r   r   r   rj   rh   r   r   rk   )rl   rm   rn   r   r  r  r   r  r   r   rz   ro   r   r   r  r<   r[   r   r   r   r   r   r   r   r   r^   r  r   r   r
  r   r    s6   
 











r  c                      sL   e Zd ZdZdZddddddd fddZd fddZd ddZ  ZS )!MSVCDynamicLinkerzMicrosoft's Link.exe.linkNr   r  r   Tr   r   r   r   r  r   r   r   r   r   T.Optional[T.List[str]]r   r|   r   r   r   r  r!   c             	     $   t  j|pdg||||||d d S )Nzlink.exer   r   r  r  r   r   r   r   r   r   r   r  r
  r   r   r   %     

zMSVCDynamicLinker.__init__r   c                   s   |  dgt   S )Nz/releaser   r  r[   r%   r
  r   r   r[   -  r   z!MSVCDynamicLinker.get_always_argsr   c                 C     |  d|  gS Nz/SUBSYSTEM:r   upperr   r   r   r   r   0  r   z(MSVCDynamicLinker.get_win_subsystem_argsr   r   r   r   r   r  r   r|   r   r   r   r   r  r!   rb   r   )	rl   rm   rn   r   r   r   r[   r   r  r   r   r
  r   r    s    r  c                      sV   e Zd ZdZdZddddddd" fddZd# fddZd$ddZd%d d!Z  Z	S )&ClangClDynamicLinkerzClang's lld-link.exe.zlld-linkNr   r  r   Tr  r   r   r   r   r   r  r   r|   r   r   r   r  r!   c             	     r  )Nzlld-link.exer  r  r  r
  r   r   r   :  r  zClangClDynamicLinker.__init__r   r   c                   s(   | j d u r| d| gS t |S )Nr   )r   r   r  r<   r   r
  r   r   r<   B  s   
z$ClangClDynamicLinker.get_output_argsr   c                 C  r  r  r  r   r   r   r   r   J  r   z+ClangClDynamicLinker.get_win_subsystem_argsr   c                 C  r  )Nz/lldltocache:r   r   r   r   r   r   M  r   z+ClangClDynamicLinker.get_thinlto_cache_argsr  r   r   r   )
rl   rm   rn   r   r   r   r<   r   r   r  r   r   r
  r   r  4  s    
r  c                      s>   e Zd ZdZdZddddddd fddZdddZ  ZS )XilinkDynamicLinkerzIntel's Xilink.exe.xilinkNr   r  r   Tr  r   r   r   r   r   r  r   r|   r   r   r   r  r!   c                  s   t  jdg|d||d d S )Nz
xilink.exer   r   r  r  r
  r   r   r   W  s   zXilinkDynamicLinker.__init__r   r   c                 C  r  r  r  r   r   r   r   r   ^  r   z*XilinkDynamicLinker.get_win_subsystem_argsr  r   )rl   rm   rn   r   r   r   r   r  r   r   r
  r   r  Q  s    r  c                   @  sd   e Zd ZdZdZd'ddZd(dd	Zd(d
dZd(ddZd(ddZ	d(ddZ
d)ddZd*d$d%Zd&S )+SolarisDynamicLinkerz5Sys-V derived linker used on Solaris and OpenSolaris.z
ld.solarisr   r   r   c                 C  re  rf  r_  r   r   r   r   r   h  rg  z'SolarisDynamicLinker.get_link_whole_forc                 C  sV   t | j| d \}}}|| dD ]}d|v r(d|v r%ddg  S  g S qg S )Nz-zhelp
z-z typepier  ztype=pie)r   r  r   r   r  )r   pcr	  stdeliner   r   r   r   m  s   z!SolarisDynamicLinker.get_pie_argsc                 C  s   |  ddgS )Nr  ignorer_  r%   r   r   r   r   w  rs  z&SolarisDynamicLinker.get_asneeded_argsc                 C  r)  )Nr  Zdefsr   r%   r   r   r   r   z  r   z&SolarisDynamicLinker.no_undefined_argsc                 C  r)  )Nr  Znodefsr   r%   r   r   r   r   }  r   z-SolarisDynamicLinker.get_allow_undefined_argsc                 C  r)  )Nr  zfatal-warningsr   r%   r   r   r   r     r   z#SolarisDynamicLinker.fatal_warningsr1   r2   r>   r   r?   r@   rA   rB   rC   rD   c                 C  s   |s|s|sg t  fS t|||}tdd |D }t  }	|D ]
}
|	|
d q |dkrD|| |dD ]
}
|	|
d q9d|}t|t|k rfdt|t|  }|s`|}n|d | }| 	d| |	fS )Nc                 S  s   g | ]	}t jd |qS )ry  r{  r@  r   r   r   r     r}  z9SolarisDynamicLinker.build_rpath_args.<locals>.<listcomp>r~  r   r  r  r  )
rG   rD  r   r  r  r  r  r   r  r   )r   r1   r>   r?   r@   rB   rC   r  r  r  rA  r  r  r   r   r   rI     s$   


z%SolarisDynamicLinker.build_rpath_argsr   r   r   r   r   r   c                 C  s2   |d u rdnd| }|  d| | d| | S rv  r_  )r   r1   r   r   r   r   r   rx  r   r   r   r     s   z$SolarisDynamicLinker.get_soname_argsNrh   rb   rf   r   )rl   rm   rn   r   r   r   r   r   r   r   r   rI   r   r   r   r   r   r  b  s    







r  c                      sl   e Zd ZdZdZd! fddZd!ddZd!d	d
Zd"ddZd!ddZ	d#ddZ
d$ddZd%dd Z  ZS )&AIXDynamicLinkerz Sys-V derived linker used on AIXzld.aixr   r   c                   s   |  ddgt   S )Nz	-bnoipathz-bbigtocr  r%   r
  r   r   r[     r  z AIXDynamicLinker.get_always_argsc                 C     |  dgS )Nz	-bernotokr_  r%   r   r   r   r     r(  z"AIXDynamicLinker.no_undefined_argsc                 C  r  )Nz-berokr_  r%   r   r   r   r     r(  z)AIXDynamicLinker.get_allow_undefined_argsr   r   c                 C  s   t dd|dd}|S )Nz$[.][a]([.]?([0-9]+))*([.]?([a-z]+))*z.az.so)resubreplacer   r   r   r   r     s   z!AIXDynamicLinker.get_archive_namec                 C  s   g d}|S )N)	r  z-qz-vz$out$inz&&rmz-fr  r   )r   commandr   r   r   r     s   z-AIXDynamicLinker.get_command_to_archive_shlibr   c                 C  r  r   r   r   r   r   r   r     s   z#AIXDynamicLinker.get_link_whole_forr1   r2   r>   r?   r@   rA   rB   rC   rD   c           
      C  s   t  }|dkr|| |dkr|| |D ]}|tj|| q|| j}	t|	dkr9|	ddg n|	D ]}tj
|rH|| q;| dd| t fS )Nr   r   z/usr/libz/libz
-blibpath:r  )r   r  r  rH  r   r   get_compiler_system_lib_dirsr   r  updateisdirr   rG   )
r   r1   r>   r?   r@   rB   rC   r  rA  Zsys_pathr   r   r   rI     s   


z!AIXDynamicLinker.build_rpath_argsc                 C  r  rt  r   rK   r   r   r   r     r   zAIXDynamicLinker.thread_flagsrb   r   rh   rf   rg   )rl   rm   rn   r   r   r[   r   r   r   r   r   rI   r   r  r   r   r
  r   r    s    



	

r  c                      sJ   e Zd ZdZdZddd fddZdddZdddZdddZ  Z	S )OptlinkDynamicLinkerz(Digital Mars dynamic linker for windows.optlinkr   r   r   r   r   r   r   r   c                  r  r  r  r  r
  r   r   r     s   zOptlinkDynamicLinker.__init__r   c                 C  r)   r   r   r%   r   r   r   r     r6   z-OptlinkDynamicLinker.get_allow_undefined_argsrU   c                 C  r)   r   r   rX   r   r   r   r     r,   z'OptlinkDynamicLinker.get_debugfile_argsc                 C  r)   r   r   r%   r   r   r   r[     r6   z$OptlinkDynamicLinker.get_always_argsr  rb   rj   )
rl   rm   rn   r   r   r   r   r   r[   r  r   r   r
  r   r    s    

r  c                   @  sT   e Zd ZdZdZedddZddd	Zdd
dZdddZ	dddZ
dddZdS ) 
CudaLinkerzCuda linker (nvlink)nvlinkr   r   c                  C  sH   ddg} z
t | \}}}W n
 ty   Y dS w | jdddd S )Nr  z	--versionr   Vr   )maxsplit)r   r  r  striprsplit)Zversion_cmdr  outr   r   r   parse_version   s   zCudaLinker.parse_versionr!   c                 C  r   r%  r   r%   r   r   r   r     r,   zCudaLinker.get_accepts_rspc                 C  s   ddl m} |jS )Nr   )CudaCompiler)Zcompilers.cudar  LINKER_PREFIX)r   r  r   r   r   r     s   zCudaLinker.get_lib_prefixr   c                 C  r  )Nz--warning-as-errorr   r%   r   r   r   r   $  r   zCudaLinker.fatal_warningsc                 C  r)   r   r   r%   r   r   r   r   '  r6   z#CudaLinker.get_allow_undefined_argsr1   r2   r   r   r   r   r   r   c                 C  r)   r   r   r   r   r   r   r   *  r,   zCudaLinker.get_soname_argsNr   r`   rb   r   )rl   rm   rn   r   r   staticmethodr  r   r   r   r   r   r   r   r   r   r    s    



r  c                      s~   e Zd Zddd" fd	d
Zd#ddZd#ddZd$ddZd%ddZd#ddZd&ddZ	d'ddZ
d$ddZd(d d!Z  ZS ))MetrowerksLinkerr   r   r   r   r   r   r   r   c                  r  r  r  r  r
  r   r   r   1  r  zMetrowerksLinker.__init__r   c                 C  r)  )Nz-werrorr   r%   r   r   r   r   6  r   zMetrowerksLinker.fatal_warningsc                 C  r)   r   r   r%   r   r   r   r   9  r6   z)MetrowerksLinker.get_allow_undefined_argsr!   c                 C  r   r8  r   r%   r   r   r   r   <  r6   z MetrowerksLinker.get_accepts_rspc                 C  r   r   r   r%   r   r   r   r   ?  r6   zMetrowerksLinker.get_lib_prefixc                 C  r)   r   r   r%   r   r   r   r\   B  r6   z'MetrowerksLinker.get_linker_always_argsr   c                 C  r9  r0  r   r   r   r   r   r<   E  r   z MetrowerksLinker.get_output_argsr   c                 C  rr  rM  r_  r   r   r   r   r   H  rs  z MetrowerksLinker.get_search_argsc                 C  r   r%  r   r%   r   r   r   r  K  r6   z$MetrowerksLinker.invoked_by_compilerr   c                 C  r   r   r   r%   r   r   r   r^   N  r   z MetrowerksLinker.rsp_file_syntaxr  rb   r`   r   r   r   rk   )rl   rm   rn   r   r   r   r   r   r\   r<   r   r  r^   r  r   r   r
  r   r  /  s    







r  c                   @  r  )MetrowerksLinkerARMr;  Nr  r   r   r   r   r  R  r  r  c                   @  r  )MetrowerksLinkerEmbeddedPowerPCr=  Nr  r   r   r   r   r  V  r  r  )r>  rA   r>   r   r?   r   r   r   )rE  r   r   r   )rA  r   r>   r   r?   r   r   r   )Q
__future__r   r   rH  typingr  r  baser   r   r   r   r   r	   arglistr   r  coredatar   environmentr   r   r   ABCMetarq   ZStaticLinkerBaseZDynamicLinkerBaseobjectr   r   r   r   r  r  r  r   r,  r.  r1  r3  r6  r7  r:  r<  rD  rC  r?  rK  rN  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  NvidiaHPC_DynamicLinkerr  ZNvidiaHPC_StaticLinkerr  r  r  r  r  r  r  r  r  r  r  r   r   r   r   <module>   s   P E!!

	
	 5W)"++&%KAA4#