From 772fd9433609468f6d2ec710ca0046dcddf60b68 Mon Sep 17 00:00:00 2001 From: baldurk Date: Sat, 7 Jun 2014 13:50:26 +0100 Subject: [PATCH] As a slight hack, reference glXWaitGL to pull in libGL in the right order * Basically we want libGL to be loaded second, after librenderdoc. This is in order to make sure dlsym(RTLD_NEXT) can work. * This can be done just by order in the ld command. Unfortunately since renderdoccmd links directly against librenderdoc (rather than LD_PRELOAD) any symbols exported by librenderdoc resolve, so unless we reference a function that isn't exported by librenderdoc, libGL won't be linked in at all. * I realise this is probably a horrible hack, but it works for now. --- renderdoccmd/Makefile | 4 ++-- renderdoccmd/linux_specific.cpp | 12 +++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/renderdoccmd/Makefile b/renderdoccmd/Makefile index c7d27cae2..c31957f03 100644 --- a/renderdoccmd/Makefile +++ b/renderdoccmd/Makefile @@ -5,9 +5,9 @@ MACROS=-DLINUX \ -DRENDERDOC_EXPORTS \ -DGIT_COMMIT_HASH='"'$$(git rev-parse HEAD)'"' \ -DRENDERDOC_VERSION_STRING='"0.20"' -CFLAGS=-c -Wall -Werror -fPIC $(MACROS) -I. +CFLAGS=-c -Wall -Werror -fPIC $(MACROS) -I../renderdoc/ CPPFLAGS=-std=c++11 -g -Wno-unused -Wno-unknown-pragmas -Wno-reorder -LDFLAGS=-L../renderdoc -lrenderdoc +LDFLAGS=-L../renderdoc -lrenderdoc -lGL OBJECTS=linux_specific.o all: bin/renderdoccmd diff --git a/renderdoccmd/linux_specific.cpp b/renderdoccmd/linux_specific.cpp index d9fb558fe..525ca40a9 100644 --- a/renderdoccmd/linux_specific.cpp +++ b/renderdoccmd/linux_specific.cpp @@ -23,9 +23,19 @@ ******************************************************************************/ #include +#include + +// symbol defined in libGL but not librenderdoc. +// Forces link of libGL after renderdoc (otherwise all symbols would +// be resolved and libGL wouldn't link, meaning dlsym(RTLD_NEXT) would fai +extern "C" void glXWaitGL(); int main() { - puts("foo"); + RENDERDOC_SpawnReplayHost(NULL); + + volatile bool never_run = false; + if(never_run) glXWaitGL(); + return 0; }