Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem compiling on clang 14 #1302

Open
andrewdavidmackenzie opened this issue Apr 21, 2023 · 7 comments
Open

Problem compiling on clang 14 #1302

andrewdavidmackenzie opened this issue Apr 21, 2023 · 7 comments

Comments

@andrewdavidmackenzie
Copy link

andrewdavidmackenzie commented Apr 21, 2023

I am unable to compile sdl2-sys v0.35.2 on my macos. With a colleague we have investigated quite a bit why his compiles and my doesn't and we think it's a difference in behaviour in the -Wdeclaration-after-statement and expecially the -Werror,-Wdeclaration-after-statement command line option to clang between clang 13 and clang 14, leading to this error

error: mixing declarations and code is incompatible with standards before C99 [-Werror,-Wdeclaration-after-statement]

on clang 14, but compiling fine on clang 13.

I am not sure if this will need an issue in the code SDL lib repo, this one, or both....guidance welcome!

   Compiling sdl2-sys v0.35.2
error: failed to run custom build command for `sdl2-sys v0.35.2`

Caused by:
  process didn't exit successfully: `/Users/andrew/workspace/tryredox/orbutils/target/debug/build/sdl2-sys-ea4598fffd079bca/build-script-build` (exit status: 101)
  --- stdout
  CMAKE_TOOLCHAIN_FILE_x86_64-apple-darwin = None
  CMAKE_TOOLCHAIN_FILE_x86_64_apple_darwin = None
  HOST_CMAKE_TOOLCHAIN_FILE = None
  CMAKE_TOOLCHAIN_FILE = None
  CMAKE_GENERATOR_x86_64-apple-darwin = None
  CMAKE_GENERATOR_x86_64_apple_darwin = None
  HOST_CMAKE_GENERATOR = None
  CMAKE_GENERATOR = None
  CMAKE_PREFIX_PATH_x86_64-apple-darwin = None
  CMAKE_PREFIX_PATH_x86_64_apple_darwin = None
  HOST_CMAKE_PREFIX_PATH = None
  CMAKE_PREFIX_PATH = None
  CMAKE_x86_64-apple-darwin = None
  CMAKE_x86_64_apple_darwin = None
  HOST_CMAKE = None
  CMAKE = None
  running: cd "/Users/andrew/workspace/tryredox/orbutils/target/debug/build/sdl2-sys-48ae333c52698e22/out/build" && CMAKE_PREFIX_PATH="" "cmake" "/Users/andrew/.cargo/registry/src/index.crates.io-6f17d22bba15001f/sdl2-sys-0.35.2/SDL" "-DCMAKE_OSX_ARCHITECTURES=x86_64" "-DSDL_SHARED=OFF" "-DSDL_STATIC=ON" "-DCMAKE_INSTALL_PREFIX=/Users/andrew/workspace/tryredox/orbutils/target/debug/build/sdl2-sys-48ae333c52698e22/out" "-DCMAKE_C_FLAGS= -D__FLTUSED__ -ffunction-sections -fdata-sections -fPIC -m64 -arch x86_64" "-DCMAKE_C_COMPILER=/usr/bin/cc" "-DCMAKE_CXX_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64 -arch x86_64" "-DCMAKE_CXX_COMPILER=/usr/bin/c++" "-DCMAKE_ASM_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64 -arch x86_64" "-DCMAKE_ASM_COMPILER=/usr/bin/cc" "-DCMAKE_BUILD_TYPE=release"
  -- dynamic libusb-1.0 -> libusb-1.0.dylib
  -- 
  -- SDL2 was configured with the following options:
  -- 
  -- Platform: Darwin-22.3.0
  -- 64-bit:   TRUE
  -- Compiler: /usr/bin/cc
  -- Revision: 
  -- 
  -- Subsystems:
  --   Atomic:  ON
  --   Audio:   ON
  --   Video:   ON
  --   Render:  ON
  --   Events:  ON
  --   Joystick:        ON
  --   Haptic:  ON
  --   Hidapi:  ON
  --   Power:   ON
  --   Threads: ON
  --   Timers:  ON
  --   File:    ON
  --   Loadso:  ON
  --   CPUinfo: ON
  --   Filesystem:      ON
  --   Dlopen:  ON
  --   Sensor:  ON
  --   Locale:  ON
  -- 
  -- Options:
  --   SDL_3DNOW                   (Wanted: ON): ON
  --   SDL_ALSA                    (Wanted: OFF): OFF
  --   SDL_ALSA_SHARED             (Wanted: OFF): OFF
  --   SDL_ALTIVEC                 (Wanted: ON): OFF
  --   SDL_ARMNEON                 (Wanted: OFF): OFF
  --   SDL_ARMSIMD                 (Wanted: OFF): OFF
  --   SDL_ARTS                    (Wanted: OFF): OFF
  --   SDL_ARTS_SHARED             (Wanted: OFF): OFF
  --   SDL_ASAN                    (Wanted: OFF): OFF
  --   SDL_ASSEMBLY                (Wanted: ON): ON
  --   SDL_ASSERTIONS              (Wanted: auto): auto
  --   SDL_BACKGROUNDING_SIGNAL    (Wanted: OFF): OFF
  --   SDL_CLOCK_GETTIME           (Wanted: OFF): OFF
  --   SDL_COCOA                   (Wanted: ON): ON
  --   SDL_DIRECTFB                (Wanted: OFF): OFF
  --   SDL_DIRECTFB_SHARED         (Wanted: OFF): OFF
  --   SDL_DIRECTX                 (Wanted: OFF): OFF
  --   SDL_DISKAUDIO               (Wanted: ON): ON
  --   SDL_DUMMYAUDIO              (Wanted: ON): ON
  --   SDL_DUMMYVIDEO              (Wanted: ON): ON
  --   SDL_ESD                     (Wanted: OFF): OFF
  --   SDL_ESD_SHARED              (Wanted: OFF): OFF
  --   SDL_FOREGROUNDING_SIGNAL    (Wanted: OFF): OFF
  --   SDL_FUSIONSOUND             (Wanted: OFF): OFF
  --   SDL_FUSIONSOUND_SHARED      (Wanted: OFF): OFF
  --   SDL_GCC_ATOMICS             (Wanted: ON): ON
  --   SDL_HIDAPI_JOYSTICK         (Wanted: ON): ON
  --   SDL_JACK                    (Wanted: OFF): OFF
  --   SDL_JACK_SHARED             (Wanted: OFF): OFF
  --   SDL_KMSDRM                  (Wanted: OFF): OFF
  --   SDL_KMSDRM_SHARED           (Wanted: OFF): OFF
  --   SDL_LIBC                    (Wanted: ON): ON
  --   SDL_LIBSAMPLERATE           (Wanted: OFF): OFF
  --   SDL_LIBSAMPLERATE_SHARED    (Wanted: OFF): OFF
  --   SDL_METAL                   (Wanted: ON): ON
  --   SDL_MMX                     (Wanted: ON): ON
  --   SDL_NAS                     (Wanted: OFF): OFF
  --   SDL_NAS_SHARED              (Wanted: OFF): OFF
  --   SDL_OFFSCREEN               (Wanted: OFF): OFF
  --   SDL_OPENGL                  (Wanted: ON): ON
  --   SDL_OPENGLES                (Wanted: ON): ON
  --   SDL_OSS                     (Wanted: OFF): OFF
  --   SDL_PIPEWIRE                (Wanted: OFF): OFF
  --   SDL_PIPEWIRE_SHARED         (Wanted: OFF): OFF
  --   SDL_PTHREADS                (Wanted: ON): ON
  --   SDL_PTHREADS_SEM            (Wanted: ON): ON
  --   SDL_PULSEAUDIO              (Wanted: OFF): OFF
  --   SDL_PULSEAUDIO_SHARED       (Wanted: OFF): OFF
  --   SDL_RENDER_D3D              (Wanted: OFF): OFF
  --   SDL_RENDER_METAL            (Wanted: ON): ON
  --   SDL_RPATH                   (Wanted: OFF): OFF
  --   SDL_RPI                     (Wanted: OFF): OFF
  --   SDL_SNDIO                   (Wanted: OFF): OFF
  --   SDL_SNDIO_SHARED            (Wanted: OFF): OFF
  --   SDL_SSE                     (Wanted: ON): ON
  --   SDL_SSE2                    (Wanted: ON): ON
  --   SDL_SSE3                    (Wanted: ON): ON
  --   SDL_SSEMATH                 (Wanted: ON): ON
  --   SDL_STATIC_PIC              (Wanted: OFF): OFF
  --   SDL_TEST                    (Wanted: OFF): OFF
  --   SDL_VIRTUAL_JOYSTICK        (Wanted: ON): ON
  --   SDL_VIVANTE                 (Wanted: OFF): OFF
  --   SDL_VULKAN                  (Wanted: ON): ON
  --   SDL_WASAPI                  (Wanted: OFF): OFF
  --   SDL_WAYLAND                 (Wanted: OFF): OFF
  --   SDL_WAYLAND_LIBDECOR        (Wanted: ON): OFF
  --   SDL_WAYLAND_LIBDECOR_SHARED (Wanted: ON): OFF
  --   SDL_WAYLAND_QT_TOUCH        (Wanted: OFF): OFF
  --   SDL_WAYLAND_SHARED          (Wanted: OFF): OFF
  --   SDL_X11                     (Wanted: OFF): OFF
  --   SDL_X11_SHARED              (Wanted: OFF): OFF
  --   SDL_X11_XCURSOR             (Wanted: OFF): OFF
  --   SDL_X11_XDBE                (Wanted: OFF): OFF
  --   SDL_X11_XFIXES              (Wanted: OFF): OFF
  --   SDL_X11_XINERAMA            (Wanted: OFF): OFF
  --   SDL_X11_XINPUT              (Wanted: OFF): OFF
  --   SDL_X11_XRANDR              (Wanted: OFF): OFF
  --   SDL_X11_XSCRNSAVER          (Wanted: OFF): OFF
  --   SDL_X11_XSHAPE              (Wanted: OFF): OFF
  --   SDL_X11_XVM                 (Wanted: OFF): OFF
  --   SDL_XINPUT                  (Wanted: OFF): OFF
  -- 
  --  CFLAGS:         -D__FLTUSED__ -ffunction-sections -fdata-sections -fPIC -m64 -arch x86_64 -idirafter "/Users/andrew/.cargo/registry/src/index.crates.io-6f17d22bba15001f/sdl2-sys-0.35.2/SDL/src/video/khronos" -I/usr/local/Cellar/libusb/1.0.26/include/libusb-1.0
  --  EXTRA_CFLAGS:  -D_THREAD_SAFE -msse3 -msse2 -msse -m3dnow -mmmx -Wshadow -fvisibility=hidden -Wdeclaration-after-statement -Werror=declaration-after-statement -fno-strict-aliasing -Wall 
  --  EXTRA_LDFLAGS: -Wl,-undefined,error;-Wl,-compatibility_version,1.0.0;-Wl,-current_version,19.0.0;-Wl,-weak_framework,GameController;-Wl,-weak_framework,Metal;-Wl,-weak_framework,QuartzCore;-Wl,-weak_framework,CoreHaptics
  --  EXTRA_LIBS:    m;iconv;/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk/System/Library/Frameworks/CoreVideo.framework;/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk/System/Library/Frameworks/Cocoa.framework;/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk/System/Library/Frameworks/IOKit.framework;/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk/System/Library/Frameworks/ForceFeedback.framework;/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk/System/Library/Frameworks/Carbon.framework;/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk/System/Library/Frameworks/CoreAudio.framework;/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk/System/Library/Frameworks/AudioToolbox.framework;/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk/System/Library/Frameworks/AVFoundation.framework;/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk/System/Library/Frameworks/Foundation.framework
  -- 
  --  Build Shared Library: OFF
  --  Build Static Library: ON
  --  Build Static Library with Position Independent Code: OFF
  -- 
  -- If something was not detected, although the libraries
  -- were installed, then make sure you have set the
  -- CFLAGS and LDFLAGS environment variables correctly.
  -- 
  -- Configuring done (0.1s)
  -- Generating done (0.0s)
  -- Build files have been written to: /Users/andrew/workspace/tryredox/orbutils/target/debug/build/sdl2-sys-48ae333c52698e22/out/build
  running: cd "/Users/andrew/workspace/tryredox/orbutils/target/debug/build/sdl2-sys-48ae333c52698e22/out/build" && MAKEFLAGS="-j --jobserver-fds=8,9 --jobserver-auth=8,9" "cmake" "--build" "." "--target" "install" "--config" "release"
  [  2%] Built target SDL2main
  [  2%] Building C object CMakeFiles/SDL2-static.dir/src/file/cocoa/SDL_rwopsbundlesupport.m.o
  [  2%] Building C object CMakeFiles/SDL2-static.dir/src/hidapi/SDL_hidapi.c.o
  [  3%] Building C object CMakeFiles/SDL2-static.dir/src/render/vitagxm/SDL_render_vita_gxm.c.o
  [  3%] Building C object CMakeFiles/SDL2-static.dir/src/render/vitagxm/SDL_render_vita_gxm_memory.c.o
  [  4%] Building C object CMakeFiles/SDL2-static.dir/src/render/vitagxm/SDL_render_vita_gxm_tools.c.o
  [  4%] Building C object CMakeFiles/SDL2-static.dir/src/stdlib/SDL_crc32.c.o
  [  4%] Building C object CMakeFiles/SDL2-static.dir/src/render/software/SDL_triangle.c.o
  [  5%] Building C object CMakeFiles/SDL2-static.dir/src/sensor/SDL_sensor.c.o
  [  7%] Building C object CMakeFiles/SDL2-static.dir/src/stdlib/SDL_getenv.c.o
  [  7%] Building C object CMakeFiles/SDL2-static.dir/src/stdlib/SDL_iconv.c.o
  [  7%] Building C object CMakeFiles/SDL2-static.dir/src/stdlib/SDL_malloc.c.o
  [  8%] Building C object CMakeFiles/SDL2-static.dir/src/stdlib/SDL_qsort.c.o
  [  8%] Building C object CMakeFiles/SDL2-static.dir/src/stdlib/SDL_stdlib.c.o
  [  9%] Building C object CMakeFiles/SDL2-static.dir/src/stdlib/SDL_string.c.o
  [ 10%] Building C object CMakeFiles/SDL2-static.dir/src/stdlib/SDL_strtokr.c.o
  [ 11%] Building C object CMakeFiles/SDL2-static.dir/src/thread/SDL_thread.c.o
  [ 11%] Building C object CMakeFiles/SDL2-static.dir/src/timer/SDL_timer.c.o
  [ 11%] Building C object CMakeFiles/SDL2-static.dir/src/video/SDL_RLEaccel.c.o
  [ 12%] Building C object CMakeFiles/SDL2-static.dir/src/video/SDL_blit.c.o
  [ 13%] Building C object CMakeFiles/SDL2-static.dir/src/video/SDL_blit_0.c.o
  [ 13%] Building C object CMakeFiles/SDL2-static.dir/src/video/SDL_blit_1.c.o
  [ 14%] Building C object CMakeFiles/SDL2-static.dir/src/video/SDL_blit_A.c.o
  [ 14%] Building C object CMakeFiles/SDL2-static.dir/src/video/SDL_blit_N.c.o

  --- stderr
  /Users/andrew/.cargo/registry/src/index.crates.io-6f17d22bba15001f/sdl2-sys-0.35.2/SDL/src/hidapi/SDL_hidapi.c:252:72: warning: 'kIOMasterPortDefault' is deprecated: first deprecated in macOS 12.0 [-Wdeprecated-declarations]
      SDL_HIDAPI_discovery.m_notificationPort = IONotificationPortCreate(kIOMasterPortDefault);
                                                                         ^~~~~~~~~~~~~~~~~~~~
                                                                         kIOMainPortDefault
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk/System/Library/Frameworks/IOKit.framework/Headers/IOKitLib.h:133:19: note: 'kIOMasterPortDefault' has been explicitly marked deprecated here
  const mach_port_t kIOMasterPortDefault
                    ^
  In file included from /Users/andrew/.cargo/registry/src/index.crates.io-6f17d22bba15001f/sdl2-sys-0.35.2/SDL/src/hidapi/SDL_hidapi.c:578:
  /Users/andrew/.cargo/registry/src/index.crates.io-6f17d22bba15001f/sdl2-sys-0.35.2/SDL/src/hidapi/mac/hid.c:163:23: error: mixing declarations and code is incompatible with standards before C99 [-Werror,-Wdeclaration-after-statement]
          struct input_report *rpt = dev->input_reports;
                               ^
  /Users/andrew/.cargo/registry/src/index.crates.io-6f17d22bba15001f/sdl2-sys-0.35.2/SDL/src/hidapi/mac/hid.c:265:11: error: mixing declarations and code is incompatible with standards before C99 [-Werror,-Wdeclaration-after-statement]
                  CFIndex str_len = CFStringGetLength(str);
                          ^
  /Users/andrew/.cargo/registry/src/index.crates.io-6f17d22bba15001f/sdl2-sys-0.35.2/SDL/src/hidapi/mac/hid.c:304:11: error: mixing declarations and code is incompatible with standards before C99 [-Werror,-Wdeclaration-after-statement]
                  CFIndex str_len = CFStringGetLength(str);
                          ^
  /Users/andrew/.cargo/registry/src/index.crates.io-6f17d22bba15001f/sdl2-sys-0.35.2/SDL/src/hidapi/mac/hid.c:576:11: warning: variable 'len' set but not used [-Wunused-but-set-variable]
                          size_t len;
                                 ^
  /Users/andrew/.cargo/registry/src/index.crates.io-6f17d22bba15001f/sdl2-sys-0.35.2/SDL/src/hidapi/mac/hid.c:563:19: error: mixing declarations and code is incompatible with standards before C99 [-Werror,-Wdeclaration-after-statement]
                  extern SDL_bool IOS_SupportedHIDDevice(IOHIDDeviceRef device);
                                  ^
  /Users/andrew/.cargo/registry/src/index.crates.io-6f17d22bba15001f/sdl2-sys-0.35.2/SDL/src/hidapi/mac/hid.c:533:11: error: mixing declarations and code is incompatible with standards before C99 [-Werror,-Wdeclaration-after-statement]
          CFSetRef device_set = IOHIDManagerCopyDevices(hid_mgr);
                   ^
  /Users/andrew/.cargo/registry/src/index.crates.io-6f17d22bba15001f/sdl2-sys-0.35.2/SDL/src/hidapi/mac/hid.c:744:25: error: mixing declarations and code is incompatible with standards before C99 [-Werror,-Wdeclaration-after-statement]
          CFRunLoopSourceContext ctx;
                                 ^
  /Users/andrew/.cargo/registry/src/index.crates.io-6f17d22bba15001f/sdl2-sys-0.35.2/SDL/src/hidapi/mac/hid.c:850:34: error: mixing declarations and code is incompatible with standards before C99 [-Werror,-Wdeclaration-after-statement]
                                  struct hid_device_list_node *node = (struct hid_device_list_node *)calloc(1, sizeof(struct hid_device_list_node));
                                                               ^
  /Users/andrew/.cargo/registry/src/index.crates.io-6f17d22bba15001f/sdl2-sys-0.35.2/SDL/src/hidapi/mac/hid.c:821:10: warning: variable 'len' set but not used [-Wunused-but-set-variable]
                  size_t len;
                         ^
  /Users/andrew/.cargo/registry/src/index.crates.io-6f17d22bba15001f/sdl2-sys-0.35.2/SDL/src/hidapi/mac/hid.c:814:11: error: mixing declarations and code is incompatible with standards before C99 [-Werror,-Wdeclaration-after-statement]
          CFSetRef device_set = IOHIDManagerCopyDevices(hid_mgr);
                   ^
  /Users/andrew/.cargo/registry/src/index.crates.io-6f17d22bba15001f/sdl2-sys-0.35.2/SDL/src/hidapi/mac/hid.c:1090:6: error: mixing declarations and code is incompatible with standards before C99 [-Werror,-Wdeclaration-after-statement]
          int skipped_report_id = 0;
              ^
  3 warnings and 9 errors generated.
  gmake[2]: *** [CMakeFiles/SDL2-static.dir/build.make:496: CMakeFiles/SDL2-static.dir/src/hidapi/SDL_hidapi.c.o] Error 1
  gmake[2]: *** Waiting for unfinished jobs....
  /Users/andrew/.cargo/registry/src/index.crates.io-6f17d22bba15001f/sdl2-sys-0.35.2/SDL/src/file/cocoa/SDL_rwopsbundlesupport.m:45:20: error: mixing declarations and code is incompatible with standards before C99 [-Werror,-Wdeclaration-after-statement]
      NSFileManager* file_manager = [NSFileManager defaultManager];
                     ^
  1 error generated.
  gmake[2]: *** [CMakeFiles/SDL2-static.dir/build.make:76: CMakeFiles/SDL2-static.dir/src/file/cocoa/SDL_rwopsbundlesupport.m.o] Error 1
  gmake[1]: *** [CMakeFiles/Makefile2:112: CMakeFiles/SDL2-static.dir/all] Error 2
  gmake: *** [Makefile:136: all] Error 2
  thread 'main' panicked at '
  command did not execute successfully, got: exit status: 2

  build script failed, must exit now', /Users/andrew/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cmake-0.1.50/src/lib.rs:1098:5
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
@andrewdavidmackenzie
Copy link
Author

andrewdavidmackenzie commented Apr 21, 2023

If anyone using clang 14 able to reproduce the error, or build successfully (meaning I got it wrong and need to look more!!) ?

@freewilll
Copy link

Looks like this has been fixed in master with a new SDL submodule (release-2.26.4 vs a1e992b). Would someone be so kind to tag a release?

RMcTn added a commit to RMcTn/Chip-8-emulator-again that referenced this issue Apr 24, 2023
@andrewdavidmackenzie
Copy link
Author

Ping: Any comment on the possibility of a release that includes the fix that seems to be in HEAD?
Thanks

@Cobrand
Copy link
Member

Cobrand commented Apr 27, 2023

Ping: Any comment on the possibility of a release that includes the fix that seems to be in HEAD? Thanks

Reference the master commit in your Cargo.toml until a new release is done:

  • There are many things left to do before a new release
  • I have been the only maintainer for years and I don't have the time right now

I hope you understand.

@andrewdavidmackenzie
Copy link
Author

I am one crate removed from it, but I think I can do a patch for dependencies and so will try that.

I commiserate on the maintenance and understand!
Just know that your work is appreciated (and anticipated! :-) ) 💪

@tedsteen
Copy link

tedsteen commented Aug 2, 2023

I'm having the same problem, anything I can do to help out to move forward to a release?

@Cobrand
Copy link
Member

Cobrand commented Aug 2, 2023

I'm having the same problem, anything I can do to help out to move forward to a release?

#1323 and #1241 need to be fixed before a new release is done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants