• 10 dec 2017: forum version update. In case of issues use this topic.
  • 30 nov 2017: pilight moved servers. In case of issues use this topic.
Hello There, Guest! Login Register


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Compile with Optimization fails / timedate missing
#1
Hello,

if I compile the GIT version with this usual gcc flags (in compile.sh)
Code:
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS="-fomit-frame-pointer -march=native -O2" -DCMAKE_CXX_FLAGS="-march=native -O2"

I'll get this (additional) warnings
Code:
/usr/local/src/pilight/libs/pilight/lua_c/config/devices/datetime.c: In function ‘plua_config_device_datetime_get_table’:
/usr/local/src/pilight/libs/pilight/lua_c/config/devices/datetime.c:301:6: warning: ‘tm.tm_wday’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  int weekday = tm.tm_wday;
      ^~~~~~~
/usr/local/src/pilight/libs/pilight/lua_c/config/devices/datetime.c:295:23: warning: ‘tm.tm_year’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  int year = tm.tm_year+1900;
             ~~~~~~~~~~^~~~~
/usr/local/src/pilight/libs/pilight/lua_c/config/devices/datetime.c:296:23: warning: ‘tm.tm_mon’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  int month = tm.tm_mon+1;
              ~~~~~~~~~^~
/usr/local/src/pilight/libs/pilight/lua_c/config/devices/datetime.c:297:6: warning: ‘tm.tm_mday’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  int day = tm.tm_mday;
      ^~~
/usr/local/src/pilight/libs/pilight/lua_c/config/devices/datetime.c:298:6: warning: ‘tm.tm_hour’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  int hour = tm.tm_hour;
      ^~~~
/usr/local/src/pilight/libs/pilight/lua_c/config/devices/datetime.c:299:6: warning: ‘tm.tm_min’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  int minute = tm.tm_min;
      ^~~~~~
/usr/local/src/pilight/libs/pilight/lua_c/config/devices/datetime.c:300:6: warning: ‘tm.tm_sec’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  int second = tm.tm_sec;
      ^~~~~~

but package builds normally (debian stretch / rpi2), just to fail later after install and start complaining about missing timedate protocol.

Any hints, what could have gone wrong?
(btw '-march=native -O0 works')

Stefan
 
Reply
#2
I don't know. I also don't see the reason to change the default compile parameters?
 
Reply
#3
(04-13-2019, 06:31 PM)curlymo Wrote: I don't know. I also don't see the reason to change the default compile parameters?

Too lower memory footprint and reduce execution time. -O2 is the debian default.
(See https://gcc.gnu.org/onlinedocs/gcc/Optim...tions.html)

But ok, I look, where missing "complete boolean eval" will kill timedate..

Stefan


PS: With the latest hardware to lua changes in GIT my sensors only every now and then get results through.
      (1 or 2 messages/min instead of more then 20 ... just to note)
 
Reply
#4
The optimization flag isn't set anywhere so it should use the default.

Regarding the second issue, please open a new topic with it.
 
Reply
#5
Just to close this:

Code:
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS="-march=native -O2 -fno-tree-sra -fno-unit-at-a-time -Wall -Werror=maybe-uninitialized" -DCMAKE_CXX_FLAGS="-march=native -O2 -fno-tree-sra -fno-unit-at-a-time -Wall -Werror=maybe-uninitialized"

in compile.sh will do just fine.

Without "-fno-tree-sra" compiler reports "maybe uninitialized" timedate vars - protocol is missing afterwards.
Without "-fno-unit-at-a-time" pilight-daemon reports:
Code:
[Apr 28 19:38:25:593489] pilight-daemon: ERROR: /usr/local/lib/pilight/storage/json/settings.lua: does not return a table
[Apr 28 19:38:25:593695] pilight-daemon: ERROR: /usr/local/lib/pilight/storage/json/registry.lua: does not return a table

No noticable loss by this -fnos, though... ignored.

Bye,
Stefan
 
Reply
#6
Can you tell me why you set the other flags?

I'm going to implement O2 soon.
 
Reply
#7
(04-28-2019, 09:16 PM)curlymo Wrote: Can you tell me why you set the other flags?


You can check, which optimizations are really enabled by
Code:
gcc -march=native -O2 -fno-tree-sra -fno-unit-at-a-time -Q --help=optimizers

explained here: https://gcc.gnu.org/onlinedocs/gcc/Optim...tions.html


Code:
-march=native
- Use current cpu architecture-dependend instructions (eg. ARMv6 / ARMv7 / FPU...)
  (see "gcc -march=native -Q --help=target")
- Runs only on the this sort of machine (not for package deployment!)


Code:
-Wall
- Enable all warnings.

Code:
-Werror=maybe-uninitialized
- Transforms "warning: ‘tm.tm_year’ may be used uninitialized" into an error, to stop compile
- Used to check, which of the 41+ flags produced the faulty build

Regards,
Stefan

BTW: debug builds should use -Og instead of -O2 (or you'll get out "optimized out" in core dumps)
 
Reply
  


Possibly Related Threads...
Thread Author Replies Views Last Post
  pilight fails starting on boot Alex 5 462 06-09-2019, 06:02 PM
Last Post: curlymo
  arctech_contact protocol missing open/close signals Niek 2 584 12-23-2017, 07:16 PM
Last Post: Niek
Question window sensor's very first signal goes missing baf 1 670 11-14-2017, 10:36 PM
Last Post: curlymo
  rule fails with ping state pinu 1 888 06-09-2017, 10:14 AM
Last Post: Niek
  cannot compile pilight on SLES 11.4 wseifert 0 703 06-09-2017, 05:59 AM
Last Post: wseifert
  config device #1 "living", missing protocol jjlf 5 1,832 11-08-2016, 11:55 PM
Last Post: jjlf
  new install fails - dev/nightly gneandr 11 8,899 01-29-2016, 11:30 AM
Last Post: WEBcast
  SSDP error and or missing protocol rudig 5 2,364 01-29-2016, 08:57 AM
Last Post: rudig

Forum Jump:


Browsing: 1 Guest(s)