Forum > Embedded - AVR

FPC 3.3.1 for AVR – compilation error on Windows 7

(1/1)

ackarwow:
I am using FPC 3.3.1 compiled for AVRs (sources from october 2024, not very old), and in some specific cases (on Win 7, 64-bit, program source file must be located in path containing space(s)) the compiler returns error – „could not open elf file”.

Execution path (many definitions starting with -d are not important here):


--- Code: Text  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---"C:\Program Files\AVRPascal\bin\win64\pp.exe" -n "-FuC:\Program Files\AVRPascal\lib\avr" "-FuC:\Program Files\AVRPascal\lib" "-FUC:\Program Files\AVRPascal\out" -Tembedded -Sg -Si -a -al -gw2 -B -va -vi -vw -vn -vh -O3 -CpAVR5 -WpATMEGA328P -XPavr- -Sm -dATMEGA328P -dAVR5 -dFAMILYMEGA -dF_CPU:=16000000 -dAVRPASCAL -dAVRPASCAL_VERSION:=3 -dAVRPASCAL_RELEASE:=1 -dAVRPASCAL_PATH:=0 -dAVRPASCAL_BUILD:=2429 -dAVRPASCAL_FULLVERSION:=30100 "C:\Program Files\AVRPascal\examples\TestBlink.pas" 
Compiler output:


--- Code: Text  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---(...)[0.922] Searching file C:\Program Files\AVRPascal\bin\win64\avr-ld.exe... found[0.922] Using util C:\Program Files\AVRPascal\bin\win64\avr-ld.exe[0.922] Executing "C:\Program Files\AVRPascal\bin\win64\avr-ld.exe" with command line "-g     --gc-sections   -L. -o "C:\Program Files\AVRPascal\examples\TestBlink.elf" -T link2792.res"[0.969] TestBlink.pas(27) Fatal: Can't open executable "C:\Program Files\AVRPascal\examples\TestBlink.elf"[0.969] Fatal: Compilation aborted 
On Win 10 it works perfectly without errors. I analyzed sources of the compiler and it seems to me that problem is related to quotes in the path. It is a bit strange, but in t_embed.pas TlinkerEmbedded.MakeExecutable method, the filename passed to PostProcessExecutable should not contain quotes. When I made the following changes (highlighted) everything seem to work:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---function TlinkerEmbedded.MakeExecutable:boolean;var  binstr,  cmdstr,  mapstr: TCmdStr;  success : boolean;  StaticStr,  GCSectionsStr,  DynLinkStr,  StripStr,  ElfStr, //added by @ackarwow  FixedExeFileName: string;begin  { for future use }  StaticStr:='';  StripStr:='';  mapstr:='';  DynLinkStr:='';  ElfStr:=ScriptFixFileName(ChangeFileExt(current_module.exefilename,'.elf'));//changed by @ackarwow  FixedExeFileName:=maybequoted(ElfStr);//changed by @ackarwow   GCSectionsStr:='--gc-sections';  //if not(cs_link_extern in current_settings.globalswitches) then  if not(cs_link_nolink in current_settings.globalswitches) then   Message1(exec_i_linking,current_module.exefilename);   if (cs_link_map in current_settings.globalswitches) then   mapstr:='-Map '+maybequoted(ChangeFileExt(current_module.exefilename,'.map')); { Write used files and libraries }  WriteResponseFile(); { Call linker }  SplitBinCmd(Info.ExeCmd[1],binstr,cmdstr);  Replace(cmdstr,'$OPT',Info.ExtraOptions);  if not(cs_link_on_target in current_settings.globalswitches) then   begin    Replace(cmdstr,'$EXE',FixedExeFileName);    Replace(cmdstr,'$RES',(maybequoted(ScriptFixFileName(outputexedir+Info.ResName))));    Replace(cmdstr,'$STATIC',StaticStr);    Replace(cmdstr,'$STRIP',StripStr);    Replace(cmdstr,'$MAP',mapstr);    Replace(cmdstr,'$GCSECTIONS',GCSectionsStr);    Replace(cmdstr,'$DYNLINK',DynLinkStr);   end  else   begin    Replace(cmdstr,'$EXE',FixedExeFileName);    Replace(cmdstr,'$RES',maybequoted(ScriptFixFileName(outputexedir+Info.ResName)));    Replace(cmdstr,'$STATIC',StaticStr);    Replace(cmdstr,'$STRIP',StripStr);    Replace(cmdstr,'$MAP',mapstr);    Replace(cmdstr,'$GCSECTIONS',GCSectionsStr);    Replace(cmdstr,'$DYNLINK',DynLinkStr);   end;  success:=DoExec(FindUtil(utilsprefix+BinStr),cmdstr,true,false); { Remove ReponseFile }  if success and not(cs_link_nolink in current_settings.globalswitches) then   DeleteFile(outputexedir+Info.ResName); { Post process }  if success and not(cs_link_nolink in current_settings.globalswitches) then    success:=PostProcessExecutable(ElfStr,false);//changed by @ackarwow   if success and (target_info.system in [system_arm_embedded,system_avr_embedded,system_mipsel_embedded,system_xtensa_embedded]) then    begin      success:=DoExec(FindUtil(utilsprefix+'objcopy'),'-O ihex '+        FixedExeFileName+' '+        maybequoted(ScriptFixFileName(ChangeFileExt(current_module.exefilename,'.hex'))),true,false);      if success then        success:=DoExec(FindUtil(utilsprefix+'objcopy'),'-O binary '+          FixedExeFileName+' '+          maybequoted(ScriptFixFileName(ChangeFileExt(current_module.exefilename,'.bin'))),true,false);        if success and (target_info.system in systems_support_uf2) and (cs_generate_uf2 in current_settings.globalswitches) then          success := GenerateUF2(maybequoted(ScriptFixFileName(ChangeFileExt(current_module.exefilename,'.bin'))),                                 maybequoted(ScriptFixFileName(ChangeFileExt(current_module.exefilename,'.uf2'))),                                 embedded_controllers[current_settings.controllertype].flashbase);{$ifdef ARM}      if success and (current_settings.controllertype = ct_raspi2) then        success:=DoExec(FindUtil(utilsprefix+'objcopy'),'-O binary '+ FixedExeFileName + ' kernel7.img',true,false);{$endif ARM}    end;   MakeExecutable:=success;   { otherwise a recursive call to link method }end; 
Did you have similar problems, or do you have better solution? Or maybe I made a mistake somwhere…?

Edit: To reproduce this - try to compile any file on a path containing space(s) on Windows 7

Navigation

[0] Message Index

Go to full version