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

Fix cmake build issues and gcc hang #91

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

neomantra
Copy link
Contributor

There were both compiler and linker errors using CMake on both Linux and OSX. This changeset fixes them. Compiles, builds, and tests successfully on OSX (cmake and Xcode). Compiles and builds on Linux.

added #include <cstdlib> to glsl_optimizer_tests.cpp to fix:

 tests/glsl_optimizer_tests.cpp:324:180: error: ‘system’ was not declared in this scope
  int res = system("/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/usr/bin/metal metalTemp.metal -o metalTemp.o -std=ios-metal1.0 -Wno-parentheses-equality");

This was happening with cmake on both Linux (gcc) and OSX (clang),
so perhaps it is something that is taken care of by Xcode.
removed the empty definition in standalone_scaffolding.h (but kept the declaration)
and added specific definitions to the executables that need it (glslopt and glsl_test)

This multiple definition was occurring in Linux and OSX with cmake.  The changes
build properly on Linux-cmake, OSX-cmake, and OSX-xcode. The tests pass on both
OSX-builds.  The Linux-cmake tests fail, but they fail before this commit.
I do not have access to MSVC.
For some reason gcc (versions 4.6 and 4.8) optimizes out the
"Trim out variables" loop in `ir_array_reference_visitor::get_split_list`,
even we don't want it too.

If that loop disappears, then the variables are never considered split
and not removed from the list, so the optimization continues
indefinitely.

Placing a memory fence in the loop prevents it from being optimized
out; this is done just with gcc.
@neomantra neomantra changed the title Fix cmake build issues Fix cmake build issues and gcc hang Mar 19, 2015
@neomantra
Copy link
Contributor Author

I also found the problem that was causing #44. All tests pass in release mode on Linux. All these changesets build and test on OSX, but I do get some test failures that I get without this changeset as well.

@tschw
Copy link

tschw commented Jul 13, 2015

Hangs and segfaults can happen all over the place (depending on compiler version and optimization options) because old C tricks in list.h break the assumptions made by modern compilers. So, although basically on the right track, the third commit only fixes one of many symptoms of an underlying problem addressed by #104.

@neomantra
Copy link
Contributor Author

@tschw After one of my most epic debugging adventures in many years, I was just orbiting the solution. That change makes so much sense, thank you for it. I will test it out this week.

@tschw
Copy link

tschw commented Jul 13, 2015

Hahaha! Although the patch reads so nice and simple, I too had some fun debugging: When it comes to optimized executables, you have no choice but to strainfully trace the program at assembly level. In my case, the crash actually happened in the second iteration of a loop - one I could step through four times at source level.

@tschw tschw mentioned this pull request Aug 15, 2015
@cpbotha cpbotha mentioned this pull request Aug 26, 2015
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

Successfully merging this pull request may close these issues.

2 participants