blt / port_compiler

A rebar3 port compiler
MIT License
65 stars 38 forks source link

gcc errors with unicode begin-single-quote breaks compilations #67

Closed mritalian closed 3 years ago

mritalian commented 4 years ago

Newer GCC (i.e. gcc-4.2.3+) use Unicode begin-single-quote and end-single-quote (8216, 8217) when your env has LANG=en_US.UTF-8 or similar. If, then, you have a compilation error, or warning, which prints out using those unicode quotes, port compiler (ref c14c10, which is HEAD as of writing) will blow up:

{pc_compilation,exec_compiler,4, [{file,"/home/enry/media/_build/default/plugins/pc/src/pc_compilation.erl"}, {line,192}]}, {pc_compilation,compile_each,5, [{file,"/home/enry/media/_build/default/plugins/pc/src/pc_compilation.erl"}, {line,135}]}, {pc_compilation,'-compile_sources/2-lists^foldl/2-0-',3, [{file,"/home/enry/media/_build/default/plugins/pc/src/pc_compilation.erl"}, {line,96}]}, {pc_compilation,compile_sources,2, [{file,"/home/enry/media/_build/default/plugins/pc/src/pc_compilation.erl"}, {line,96}]}, {pc_compilation,compile_and_link,2, [{file,"/home/enry/media/_build/default/plugins/pc/src/pc_compilation.erl"}, {line,42}]}, {pc_prv_compile,'-do/1-lc$^0/1-0-',2, [{file,"/home/enry/media/_build/default/plugins/pc/src/pc_prv_compile.erl"}, {line,53}]}, {pc_prv_compile,do,1, [{file,"/home/enry/media/_build/default/plugins/pc/src/pc_prv_compile.erl"}, {line,54}]}]

There is call to Error = re:replace(RawError, Source, AbsSource, [{return, list}, global]),, I think re:replace is expecting a string(), not a unicode charlist().

Of course, using unicode points for quotes in lieu of and ' for compilation errors is kind of useless, so I turn it off and this "fixes" the problem:{port_env, [{"LANG", "C"}]}. But I believe it would be better if port_compiler could handle this without sending unicode points down tore:replace`.

This should be repro by export LANG=en_US.UTF-8. Kindly advise if I can assist in any way.

tolbrino commented 4 years ago

For completeness, which OTP version did you use?

mritalian commented 4 years ago

This was 21.3.8.6 built from source on Ubuntu 20.04.

On Fri., Jun. 19, 2020, 3:46 a.m. Tino Breddin, notifications@github.com wrote:

For completeness, which OTP version did you use?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/blt/port_compiler/issues/67#issuecomment-646492413, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADYOXVXO47N24XRHGNEBZXDRXMJWBANCNFSM4N42J53A .

slepher commented 3 years ago

this problem is fired after rebar3 upgraded from 3.13 to 3.14 after upgraded to rebar3-3.14 rebar_utils:sh changes behaviour and return unicode list correctly this unicode list should be formatted with ~ts or io:format will crash with bad argument