adafruit / adafruit-beaglebone-io-python

Adafruit's BeagleBone IO Python Library
http://learn.adafruit.com/setting-up-io-python-library-on-beaglebone-black
477 stars 217 forks source link

Compilation issues due to strict aliasing #133

Closed archey closed 7 years ago

archey commented 7 years ago

When compiling the adafruit beaglebone-io-python libraries on gcc 6.3.1, it fails due to strict aliasing rules. I was curious if these 3 lines could be corrected to fix the issue with compilation.

Compiliation errors

pdp7 commented 7 years ago

@archey thanks for letting us know. I'll take a look.

archey commented 7 years ago

Hows this coming along? Just curious no rush

pdp7 commented 7 years ago

@archey Thanks for the ping. I'll take a look tonight and update.

pdp7 commented 7 years ago

@archey Are you running Arch on the BeagleBone itself? If so, is there an image that I can download to test?

Currently, I'm downloading archlinux-2017.02.01-dual.iso to run in VirtualBox on my x86_64 host. This seemed like the quickest way to get GCC 6.3. I'm hoping I'll hit the error you mentioned when I try to build adafruit-beaglebone-io-python on it.

pdp7 commented 7 years ago

I'm leaning towards modifying the build to ignore the gcc strict-aliasing warning. Py_RETURN_TRUE and Py_RETURN_FALSE are part of the Python C API and I think are OK to use: https://docs.python.org/2/c-api/bool.html

pdp7 commented 7 years ago

@archey I've pushed commit baf41fc which adds -Wno-strict-aliasing to CFLAGS to ignore gcc warning. Please test and let me know how it works.

archey commented 7 years ago

@pdp7 I am testing it on all arches x86_64, i686, armv6, armv7, aarch64. I was hoping you wouldn't add the ignore flag, but Im sure it will fix the issues. You can use ArchLinux ARM to test it on the beaglebone with this image: https://archlinuxarm.org/platforms/armv7/ti/beaglebone-black or https://archlinuxarm.org/platforms/armv7/ti/beaglebone

pdp7 commented 7 years ago

@archey thanks. yeah, I don't like having to permanently ignore warnings. Py_RETURN_TRUE and Py_RETURN_FALSE seem to be necessary for the Python C API. I'm not sure how to rework the code to avoid that strict-aliasing warning for those lines.

archey commented 7 years ago

@pdp7 I understand, its not an issue in 1.0.0 the current version that we have compiled. I will test the cflag change in a bit.

pdp7 commented 7 years ago

@archey Ah, I think the reason is that I enabled extra gcc warnings in this commit: c8fe070

 else:
      kernel41 = None

 -CFLAGS = ['-Wall', '-Werror', '-Wno-format-security']
 +CFLAGS = ['-Wall', '-Werror', '-Wextra', '-Wno-format-security']

  classifiers = ['Development Status :: 3 - Alpha',
                 'Operating System :: POSIX :: Linux',

I think I didn't notice the strict aliasing warning as I'm on an older version of gcc.

archey commented 7 years ago

@pdp7 it works fine with the patch, you can commit it and maybe bump the current tag

pdp7 commented 7 years ago

Thanks, I've created a new release.