brummer10 / guitarix

guitarix virtual versatile amplification for Jack/Linux
249 stars 26 forks source link

./waf configure --optimization fail on aarch64 (Rasperry Pi) #30

Closed hfiguiere closed 5 months ago

hfiguiere commented 3 years ago

Trying to build Guitarix on Raspberry Pi 400 using the 64-bits OS (aarch64)

I configure with ./waf configure --optimization

Configure end with a Python error:

Traceback (most recent call last):
  File "/home/hub/source/org.guitarix.Guitarix/guitarix-0.41.0/.waf-2.0.19-1f3c580272b15a03d2566843c5fe872a/waflib/Scripting.py", line 119, in waf_entry_point
    run_commands()
  File "/home/hub/source/org.guitarix.Guitarix/guitarix-0.41.0/.waf-2.0.19-1f3c580272b15a03d2566843c5fe872a/waflib/Scripting.py", line 182, in run_commands
    ctx=run_command(cmd_name)
  File "/home/hub/source/org.guitarix.Guitarix/guitarix-0.41.0/.waf-2.0.19-1f3c580272b15a03d2566843c5fe872a/waflib/Scripting.py", line 173, in run_command
    ctx.execute()
  File "/home/hub/source/org.guitarix.Guitarix/guitarix-0.41.0/.waf-2.0.19-1f3c580272b15a03d2566843c5fe872a/waflib/Configure.py", line 85, in execute
    super(ConfigurationContext,self).execute()
  File "/home/hub/source/org.guitarix.Guitarix/guitarix-0.41.0/.waf-2.0.19-1f3c580272b15a03d2566843c5fe872a/waflib/Context.py", line 92, in execute
    self.recurse([os.path.dirname(g_module.root_path)])
  File "/home/hub/source/org.guitarix.Guitarix/guitarix-0.41.0/.waf-2.0.19-1f3c580272b15a03d2566843c5fe872a/waflib/Context.py", line 133, in recurse
    user_function(self)
  File "/home/hub/source/org.guitarix.Guitarix/guitarix-0.41.0/wscript", line 389, in configure
    conf.gxload('cpu_optimization')
  File "/home/hub/source/org.guitarix.Guitarix/guitarix-0.41.0/wscript", line 26, in <lambda>
    lambda ctx, tool: ctx.load(tool, tooldir='waftools')
  File "/home/hub/source/org.guitarix.Guitarix/guitarix-0.41.0/.waf-2.0.19-1f3c580272b15a03d2566843c5fe872a/waflib/Configure.py", line 156, in load
    func(self)
  File "waftools/cpu_optimization.py", line 169, in configure
    cpu_model = append_optimization_flags(conf, cxxflags)
  File "waftools/cpu_optimization.py", line 83, in append_optimization_flags
    "YELLOW")
  File "/home/hub/source/org.guitarix.Guitarix/guitarix-0.41.0/.waf-2.0.19-1f3c580272b15a03d2566843c5fe872a/waflib/Configure.py", line 175, in fun
    return f(*k,**kw)
TypeError: display_msg() takes at most 3 arguments (4 given)

The line in question is

    if cpu_model is None or x86_flags is None:
        conf.display_msg("Checking CPU Architecture",
                         "cpu model not found in /proc/cpuinfo",
                         "YELLOW")

The bug is two fold:

  1. the error reporting is broken, and I'm not sure why Python throw an error.
  2. the --optimization assume x86_64.

The former should be fixed first.

For the latter the gist is that is checks /proc/cpuinfo assuming a particular format. grep ^model\ name /proc/cpuinfo returns nothing on aarch64

Let me know if you need more info.

brummer10 commented 3 years ago

Hi Hubert Oh, yes, that is broken. Thanks for the hint. we need to define a additional display_msg_1 method in ./wscript which takes the additional 'self' argument to fix the error reporting from outside. For the latter, I've no idea how and were I could fetch CPU information for the aarch64, so I can't add any optimisation flags for it. So I'll fix the error reporting, but leave optimisations for unknown CPU's in the hand of the user.

brummer10 commented 3 years ago

A fix for the error handling is pushed to git.

hfiguiere commented 3 years ago

My concern here is that you confuse target host (the one you compile for) and builder host (the one you run the build process on). Imagine you build on a fancy AMD Ryzen with fancy extensions you enable but target a simple Intel Core i3.... Let alone building for a different architecture (but then I don't know how waf handle this anyway)

brummer10 commented 3 years ago

The only way to handle that is by the user then. Means, don't use the --optimization flag but set the flags you need for your target host.

hfiguiere commented 3 years ago

you can use lscpu it seems more consistent with the information displayed, I checked on both x86_64 and aarch64 (my RPi)

brummer10 commented 3 years ago

That's a good one. I can't remember if that was available at the time I implemented the optimization flag, but you ar right, seemd to be time to move on. If you post the output of lspcu for your aarch64, I may be able to add support for it in that run.

hfiguiere commented 3 years ago

On my Raspberry Pi 400 using the 64-bits OS (not the default)

$ lscpu
Architecture:        aarch64
Byte Order:          Little Endian
CPU(s):              4
On-line CPU(s) list: 0-3
Thread(s) per core:  1
Core(s) per socket:  4
Socket(s):           1
Vendor ID:           ARM
Model:               3
Model name:          Cortex-A72
Stepping:            r0p3
CPU max MHz:         1800.0000
CPU min MHz:         600.0000
BogoMIPS:            108.00
Flags:               fp asimd evtstrm crc32 cpuid

But this doesn't mean it's right.

falkTX commented 3 years ago

FYI it is possible that the lscpu tool is not installed

brummer10 commented 3 years ago

FYI it is possible that the lscpu tool is not installed

Yes, I would leave the old check as fallback.

On my Raspberry Pi 400 using the 64-bits OS

mm, I expected something in flags for optimize for the fpu register (-mfpu=???, -mcpu=??? )