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

Build with Guix #8

Merged
merged 1 commit into from
Feb 22, 2023
Merged

Build with Guix #8

merged 1 commit into from
Feb 22, 2023

Conversation

LiberalArtist
Copy link
Contributor

@LiberalArtist LiberalArtist commented Feb 13, 2023

Current status: See #8 (comment) to try it out!


Original Post

Currently, building with guix time-machine -C channels.scm -- build -f guix.scm --keep-failed hits the following error: I've attaching the full log as 9f5hc6rgfdmwv8wkw6rwi8n79nbkr5np-tangerine-0.0.drv.log.

/tmp/guix-build-tangerine-0.0.drv-0/source/tangerine/lua_sdf.cpp:533:11: error: no matching function for call to 'min'
                        Dist = glm::min(abs(Dist), MaxDist);
                               ^~~~~~~~
/tmp/guix-build-tangerine-0.0.drv-0/source/third_party/glm/detail/func_common.inl:17:43: note: candidate template ignored: deduced conflicting types for parameter 'genType' ('int' vs. 'float')
        GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType min(genType x, genType y)

There are a bunch of warnings like this that might or might not be related:

/tmp/guix-build-tangerine-0.0.drv-0/source/tangerine/lua_sdf.cpp:533:20: warning: using integer absolute value function 'abs' when argument is of floating point type [-Wabsolute-value]
                        Dist = glm::min(abs(Dist), MaxDist);
                                        ^
/tmp/guix-build-tangerine-0.0.drv-0/source/tangerine/lua_sdf.cpp:533:20: note: use function 'std::abs' instead
                        Dist = glm::min(abs(Dist), MaxDist);
                                        ^~~
                                        std::abs

guix.scm Outdated Show resolved Hide resolved
guix.scm Outdated Show resolved Hide resolved
@LiberalArtist
Copy link
Contributor Author

The problem very well could be in the Guix environment!

@LiberalArtist
Copy link
Contributor Author

Rebasing on 2ef412e fixed the above! Now I get the same error I saw with GCC (i.e. without clang-toolchain):

ld: CMakeFiles/tangerine.dir/third_party/imgui/backends/imgui_impl_opengl3.cpp.o: undefined reference to symbol 'dlclose@@GLIBC_2.2.5'
ld: /gnu/store/5h2w4qi9hk1qzzgi1w83220ydslinr4s-glibc-2.33/lib/libdl.so.2: error adding symbols: DSO missing from command line
clang-13: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [CMakeFiles/tangerine.dir/build.make:1109: tangerine] Error 1
make[2]: Leaving directory '/tmp/guix-build-tangerine-0.0.drv-0/build'
make[1]: *** [CMakeFiles/Makefile2:86: CMakeFiles/tangerine.dir/all] Error 2
make[1]: Leaving directory '/tmp/guix-build-tangerine-0.0.drv-0/build'
make: *** [Makefile:94: all] Error 2
error: in phase 'build': uncaught exception:
%exception #<&invoke-error program: "make" arguments: ("-j" "16") exit-status: 2 term-signal: #f stop-signal: #f> 
phase `build' failed after 27.8 seconds
command "make" "-j" "16" failed with status 2
note: keeping build directory `/tmp/guix-build-tangerine-0.0.drv-1'
builder for `/gnu/store/8bk8ia9f0pi8ziasrvh5iiwbdq46f2if-tangerine-0.0.drv' failed with exit code 1
build of /gnu/store/8bk8ia9f0pi8ziasrvh5iiwbdq46f2if-tangerine-0.0.drv failed
View build log at '/var/log/guix/drvs/8b/k8ia9f0pi8ziasrvh5iiwbdq46f2if-tangerine-0.0.drv.bz2'.
guix build: error: build of `/gnu/store/8bk8ia9f0pi8ziasrvh5iiwbdq46f2if-tangerine-0.0.drv' failed

Maybe I just need to add -ld in to target_link_libraries for cmake? I'll look into that.

@LiberalArtist
Copy link
Contributor Author

Everything now builds! But the result can't find the shaders, as I explain in more detail in a1f7315 (it might really be a linker problem).

@LiberalArtist
Copy link
Contributor Author

It works! You can build it with guix time-machine -C channels.scm -- build -f guix.scm. Finding the shaders is still a bit fragile (e.g. guix time-machine -C channels.scm -- shell -f guix.scm -- tangerine doesn't work yet), and I want to clean this up before marking it as ready for review, but you can run it with:

$(guix time-machine -C channels.scm -- build -f guix.scm)/bin/tangerine

@LiberalArtist
Copy link
Contributor Author

LiberalArtist commented Feb 14, 2023

I think this is ready! I've pared down this PR to just ("just") building with Guix, but I have work in progress toward enabling Racket, too.

The main caveat is that I don't have a setup to test that the Windows build still works.

@LiberalArtist LiberalArtist marked this pull request as ready for review February 14, 2023 01:40
@Aeva
Copy link
Owner

Aeva commented Feb 14, 2023

The main caveat is that I don't have a setup to test that the Windows build still works.

That's fine, I can fix any regressions that show up on the Windows side.

In the process, refine the Linux build.

The files `installation.h` and `installation.cpp` define a new
struct `TangerineInstallation` to encapsulate paths relative to the
executable. It helps with adapting to a more Unix-like directory
structure, with `bin` and `share` directories.

In `CMakeLists.txt`, support `cmake --install`, organize the file into
more targets, and eliminate the need to manually move `tangerine` next
to the `shaders` directory.
@LiberalArtist
Copy link
Contributor Author

I just force-pushed a typo fix to the commit message:

manually more `tangerine`
           ⬆
           v

I'm happy to use _WIN_64 or make other changes if you want, or feel free to just do them yourself.

@Aeva Aeva merged commit c2e3caf into Aeva:excelsior Feb 22, 2023
@LiberalArtist LiberalArtist mentioned this pull request Feb 23, 2023
Aeva added a commit that referenced this pull request May 12, 2023
Remarkably this change seems to prevent this use-after-free error:

==4284==ERROR: AddressSanitizer: heap-use-after-free on address 0x60700003cf50 at pc 0x7f22b904814b bp 0x7ffda5338480 sp 0x7ffda5337c30
READ of size 79 at 0x60700003cf50 thread T0
    #0 0x7f22b904814a in __interceptor_memcpy ../../../../src/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:827
    #1 0x560430138ab6 in void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char*>(char*, char*, std::forward_iterator_tag) [clone .constprop.0] (/home/aeva/Projects/tangerine/linux/build/Release/bin/tangerine+0x2f0ab6)
    #2 0x5604301421c6 in ifd::FileDialog::m_setDirectory(std::filesystem::__cxx11::path const&, bool) (/home/aeva/Projects/tangerine/linux/build/Release/bin/tangerine+0x2fa1c6)
    #3 0x5604301456aa in ifd::FileDialog::m_renderContent() (/home/aeva/Projects/tangerine/linux/build/Release/bin/tangerine+0x2fd6aa)
    #4 0x560430145e6b in ifd::FileDialog::m_renderFileDialog() (/home/aeva/Projects/tangerine/linux/build/Release/bin/tangerine+0x2fde6b)
    #5 0x5604301464f7 in ifd::FileDialog::IsDone(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (/home/aeva/Projects/tangerine/linux/build/Release/bin/tangerine+0x2fe4f7)
    #6 0x5604300678b4 in RenderUI(SDL_Window*, bool&) (/home/aeva/Projects/tangerine/linux/build/Release/bin/tangerine+0x21f8b4)
    #7 0x56043006fa0e in MainLoop() (/home/aeva/Projects/tangerine/linux/build/Release/bin/tangerine+0x227a0e)
    #8 0x56042fe898fa in main (/home/aeva/Projects/tangerine/linux/build/Release/bin/tangerine+0x418fa)
    #9 0x7f22b8967189 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    #10 0x7f22b8967244 in __libc_start_main_impl ../csu/libc-start.c:381
    #11 0x56042fe8b8c0 in _start (/home/aeva/Projects/tangerine/linux/build/Release/bin/tangerine+0x438c0)

0x60700003cf50 is located 0 bytes inside of 80-byte region [0x60700003cf50,0x60700003cfa0)
freed by thread T0 here:
    #0 0x7f22b90ba3c8 in operator delete(void*, unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cpp:164
    #1 0x56043014210a in ifd::FileDialog::m_setDirectory(std::filesystem::__cxx11::path const&, bool) (/home/aeva/Projects/tangerine/linux/build/Release/bin/tangerine+0x2fa10a)

previously allocated by thread T0 here:
    #0 0x7f22b90b94c8 in operator new(unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cpp:95
    #1 0x560430138a9b in void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char*>(char*, char*, std::forward_iterator_tag) [clone .constprop.0] (/home/aeva/Projects/tangerine/linux/build/Release/bin/tangerine+0x2f0a9b)
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.

None yet

2 participants