Verified Commit c6f1f03b authored by Camil Staps's avatar Camil Staps
Browse files

Display link errors on Windows

parent bbeba5d1
Pipeline #45932 passed with stage
in 14 seconds
......@@ -3826,7 +3826,74 @@ static int link_project (P_NODE first_project_node,char *options_file_name,char
return r>=0 && status==0;
}
# else
r=spawnv (_P_WAIT,linker_file_name_,argv);
{
static char linkerrs_file_name[]="linkerrs.$$$";
SECURITY_ATTRIBUTES sa;
STARTUPINFO si;
PROCESS_INFORMATION pi;
HANDLE linkerrs;
char buffer[32767];
char *cmd=buffer;
sa.nLength=sizeof (SECURITY_ATTRIBUTES);
sa.lpSecurityDescriptor=NULL;
sa.bInheritHandle=TRUE;
linkerrs=CreateFile (linkerrs_file_name,GENERIC_WRITE,FILE_SHARE_WRITE|FILE_SHARE_READ,&sa,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
si.cb=sizeof (STARTUPINFO);
si.lpReserved=NULL;
si.lpReserved2=NULL;
si.cbReserved2=0;
si.lpDesktop=NULL;
si.lpTitle=NULL;
si.dwFlags=STARTF_USESTDHANDLES;
si.hStdInput=GetStdHandle (STD_INPUT_HANDLE);
si.hStdOutput=linkerrs;
si.hStdError=linkerrs;
*cmd++='"';
for (char *c=linker_file_name_; *c; c++)
*cmd++=*c;
*cmd++='"';
for (arg=argv+1; *arg; arg++){
*cmd++=' ';
*cmd++='"';
for (char *c=*arg; *c; c++)
*cmd++=*c;
*cmd++='"';
}
if (!CreateProcess (linker_file_name_,buffer,NULL,NULL,TRUE,0,NULL,NULL,&si,&pi)){
fprintf (stderr,"CreateProcess failed\n");
exit (1);
}
CloseHandle (pi.hThread);
CloseHandle (linkerrs);
if (WaitForSingleObject (pi.hProcess,INFINITE)!=WAIT_OBJECT_0){
fprintf (stderr,"WaitForSingleObject failed\n");
exit (1);
}
if (!GetExitCodeProcess (pi.hProcess,&r)){
fprintf (stderr,"GetExitCodeProcess failed\n");
exit (1);
}
CloseHandle (pi.hProcess);
if ((linkerrs=fopen (linkerrs_file_name,"r"))==NULL){
fprintf (stderr,"Failed to open %s\n",linkerrs_file_name);
exit (1);
}
while (fgets (buffer,32767,linkerrs)!=NULL)
fputs (buffer,stderr);
fclose (linkerrs);
unlink (linkerrs_file_name);
}
# endif
# else
r=dos_exec (linker_file_name,argv,1);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment