pico-examples icon indicating copy to clipboard operation
pico-examples copied to clipboard

Strange characters appear when loading objects from the rsp file for the linker on windows

Open jfarhanm opened this issue 2 years ago • 6 comments

The generated link command and it inputs are as follows

	C:\PROGRA~2\GNUARM~1\102020~1\bin\AR10B2~1.EXE -mcpu=cortex-m0plus -mthumb -O3 -DNDEBUG -Wl,--build-id=none --specs=nosys.specs -Wl,--wrap=sprintf -Wl,--wrap=snprintf -Wl,--wrap=vsnprintf -Wl,--wrap=__clzsi2 -Wl,--wrap=__clzdi2 -Wl,--wrap=__ctzsi2 -Wl,--wrap=__ctzdi2 -Wl,--wrap=__popcountsi2 -Wl,--wrap=__popcountdi2 -Wl,--wrap=__clz -Wl,--wrap=__clzl -Wl,--wrap=__clzll -Wl,--wrap=__aeabi_idiv -Wl,--wrap=__aeabi_idivmod -Wl,--wrap=__aeabi_ldivmod -Wl,--wrap=__aeabi_uidiv -Wl,--wrap=__aeabi_uidivmod -Wl,--wrap=__aeabi_uldivmod -Wl,--wrap=__aeabi_dadd -Wl,--wrap=__aeabi_ddiv -Wl,--wrap=__aeabi_dmul -Wl,--wrap=__aeabi_drsub -Wl,--wrap=__aeabi_dsub -Wl,--wrap=__aeabi_cdcmpeq -Wl,--wrap=__aeabi_cdrcmple -Wl,--wrap=__aeabi_cdcmple -Wl,--wrap=__aeabi_dcmpeq -Wl,--wrap=__aeabi_dcmplt -Wl,--wrap=__aeabi_dcmple -Wl,--wrap=__aeabi_dcmpge -Wl,--wrap=__aeabi_dcmpgt -Wl,--wrap=__aeabi_dcmpun -Wl,--wrap=__aeabi_i2d -Wl,--wrap=__aeabi_l2d -Wl,--wrap=__aeabi_ui2d -Wl,--wrap=__aeabi_ul2d -Wl,--wrap=__aeabi_d2iz -Wl,--wrap=__aeabi_d2lz -Wl,--wrap=__aeabi_d2uiz -Wl,--wrap=__aeabi_d2ulz -Wl,--wrap=__aeabi_d2f -Wl,--wrap=sqrt -Wl,--wrap=cos -Wl,--wrap=sin -Wl,--wrap=tan -Wl,--wrap=atan2 -Wl,--wrap=exp -Wl,--wrap=log -Wl,--wrap=ldexp -Wl,--wrap=copysign -Wl,--wrap=trunc -Wl,--wrap=floor -Wl,--wrap=ceil -Wl,--wrap=round -Wl,--wrap=sincos -Wl,--wrap=asin -Wl,--wrap=acos -Wl,--wrap=atan -Wl,--wrap=sinh -Wl,--wrap=cosh -Wl,--wrap=tanh -Wl,--wrap=asinh -Wl,--wrap=acosh -Wl,--wrap=atanh -Wl,--wrap=exp2 -Wl,--wrap=log2 -Wl,--wrap=exp10 -Wl,--wrap=log10 -Wl,--wrap=pow -Wl,--wrap=powint -Wl,--wrap=hypot -Wl,--wrap=cbrt -Wl,--wrap=fmod -Wl,--wrap=drem -Wl,--wrap=remainder -Wl,--wrap=remquo -Wl,--wrap=expm1 -Wl,--wrap=log1p -Wl,--wrap=fma -Wl,--wrap=__aeabi_lmul -Wl,--wrap=__aeabi_fadd -Wl,--wrap=__aeabi_fdiv -Wl,--wrap=__aeabi_fmul -Wl,--wrap=__aeabi_frsub -Wl,--wrap=__aeabi_fsub -Wl,--wrap=__aeabi_cfcmpeq -Wl,--wrap=__aeabi_cfrcmple -Wl,--wrap=__aeabi_cfcmple -Wl,--wrap=__aeabi_fcmpeq -Wl,--wrap=__aeabi_fcmplt -Wl,--wrap=__aeabi_fcmple -Wl,--wrap=__aeabi_fcmpge -Wl,--wrap=__aeabi_fcmpgt -Wl,--wrap=__aeabi_fcmpun -Wl,--wrap=__aeabi_i2f -Wl,--wrap=__aeabi_l2f -Wl,--wrap=__aeabi_ui2f -Wl,--wrap=__aeabi_ul2f -Wl,--wrap=__aeabi_f2iz -Wl,--wrap=__aeabi_f2lz -Wl,--wrap=__aeabi_f2uiz -Wl,--wrap=__aeabi_f2ulz -Wl,--wrap=__aeabi_f2d -Wl,--wrap=sqrtf -Wl,--wrap=cosf -Wl,--wrap=sinf -Wl,--wrap=tanf -Wl,--wrap=atan2f -Wl,--wrap=expf -Wl,--wrap=logf -Wl,--wrap=ldexpf -Wl,--wrap=copysignf -Wl,--wrap=truncf -Wl,--wrap=floorf -Wl,--wrap=ceilf -Wl,--wrap=roundf -Wl,--wrap=sincosf -Wl,--wrap=asinf -Wl,--wrap=acosf -Wl,--wrap=atanf -Wl,--wrap=sinhf -Wl,--wrap=coshf -Wl,--wrap=tanhf -Wl,--wrap=asinhf -Wl,--wrap=acoshf -Wl,--wrap=atanhf -Wl,--wrap=exp2f -Wl,--wrap=log2f -Wl,--wrap=exp10f -Wl,--wrap=log10f -Wl,--wrap=powf -Wl,--wrap=powintf -Wl,--wrap=hypotf -Wl,--wrap=cbrtf -Wl,--wrap=fmodf -Wl,--wrap=dremf -Wl,--wrap=remainderf -Wl,--wrap=remquof -Wl,--wrap=expm1f -Wl,--wrap=log1pf -Wl,--wrap=fmaf -Wl,--wrap=malloc -Wl,--wrap=calloc -Wl,--wrap=free -Wl,--wrap=memcpy -Wl,--wrap=memset -Wl,--wrap=__aeabi_memcpy -Wl,--wrap=__aeabi_memset -Wl,--wrap=__aeabi_memcpy4 -Wl,--wrap=__aeabi_memset4 -Wl,--wrap=__aeabi_memcpy8 -Wl,--wrap=__aeabi_memset8 -Wl,-Map=blink.elf.map -Wl,--script=F:pico\pico-sdk\src\rp2_common\pico_standard_link\memmap_default.ld -Wl,-z,max-page-size=4096 -Wl,--gc-sections -Wl,--wrap=printf -Wl,--wrap=vprintf -Wl,--wrap=puts -Wl,--wrap=putchar -Wl,--wrap=getchar @CMakeFiles\blink.dir\objects1.rsp -o blink.elf  ..\pico-sdk\src\rp2_common\boot_stage2\bs2_default_padded_checksummed.S

produces an error

AR10B2~1.EXE: error: CMakeFiles/blink.dir/blink.c.obj: No such file or directory

Which is the first path in @CMakeFiles\blink.dir\objects1.rsp.

Using cmake version 3.22.2

jfarhanm avatar Jun 08 '22 09:06 jfarhanm

Duplicate of https://github.com/raspberrypi/pico-sdk/issues/725, #128, #152, #141 etc. It seems to be a "known problem" that affects some users, but not others. Unfortunately we've been unable to reproduce this error ourselves, meaning that we can't investigate it or offer a "do this" solution :slightly_frowning_face:

But maybe one of the suggestions in one of those issues will be able to help? :crossed_fingers:

lurch avatar Jun 08 '22 10:06 lurch

Thank you I think this is an issue with how @CMakeFiles\blink.dir\objects1.rsp works on windows and not necessarily a cmake issue. But I may definitely be wrong. From this post it appears the strange characters represent the Unicode byte-order mark in UTF-8. I tried replacing it with only CMakeFiles/blink.dir/blink.c.obj In the build.make file in pico\pico-examples\build\blink\CMakeFiles\blink.dir line 1073 and it seemed to link OK.

jfarhanm avatar Jun 08 '22 12:06 jfarhanm

I tried replacing it with only CMakeFiles/blink.dir/blink.c.obj In the build.make file in pico\pico-examples\build\blink\CMakeFiles\blink.dir line 1073 and it seemed to link OK.

Yeah that'll work as a temporary workaround, but that file might get automatically (over)written the next time you do a build?

I agree about the BOM thing, see e.g. https://github.com/raspberrypi/pico-examples/issues/141#issuecomment-886267520

lurch avatar Jun 08 '22 13:06 lurch

I tried copying the generated paths to another file because the first rsp file was saved as a UTF-8 encoding with BOM image and the new file I made to which I copied the contents of objects1.rsp was UTF-8. I believe cmake somehow adds the BOM characters into the paths. I tried linking with it and it worked!

jfarhanm avatar Jun 08 '22 13:06 jfarhanm

If it's worth anything, a temporary workaround is to create a new text document named objects1.rsp and copy the contents of pico\pico-examples\build\blink\CMakeFiles\blink.dir\objects1.rsp to it. and then replace the initial pico\pico-examples\build\blink\CMakeFiles\blink.dir\objects1.rsp with the new one.

jfarhanm avatar Jun 08 '22 13:06 jfarhanm

The problem appears to have been a bug in CMake which was fixed more recently. I had this running CMake 3.21.0-rc2 upgrading to the latest on cmake.org (3.24.0) has resolved the problems.

nhorlock avatar Aug 06 '22 22:08 nhorlock

Thank you. I shall close this.

jfarhanm avatar Aug 28 '22 10:08 jfarhanm