Passing a gcc flag through makefile

前端 未结 3 757
清歌不尽
清歌不尽 2020-12-05 19:44

I am trying to build a pass using llvm and I have finished building llvm and its associated components. However, when I run make after following all the steps to build a pas

3条回答
  •  無奈伤痛
    2020-12-05 20:13

    Looks like you could add the -fPIC (for position-independent code, something you want for a shared library that could be loaded at any address) by setting shell variables:

    export CFLAGS="$CFLAGS -fPIC"
    export CXXFLAGS="$CXXFLAGS -fPIC"
    

    Looking at Makefile.rules, these will be picked up and used. Seems strange that it wasn't there to begin with.

    EDIT:

    Actually, reading more in the makefiles, I found this link to the LLVM Makefile Guide. From Makefile.rules, setting either SHARED_LIBRARY=1 or LOADABLE_MODULE=1 (which implies SHARED_LIBRARY) in Makefile will put -fPIC in the compiler flags.

提交回复
热议问题