MikePopoloski / slang

SystemVerilog compiler and language services
MIT License
555 stars 120 forks source link

Option to create executable that does not have dependency on shared objects of the OS #736

Closed idjordje closed 1 year ago

idjordje commented 1 year ago

Is your feature request related to a problem? Please describe. Current build option require fairly current OS distribution and tools versions. This prevents usage in environments that that are not easy to migrate to those revisions. Building a self sufficient (statically linked) executable) would allow building on an isolated system and distributing (plain copy) to older systems.

Describe the solution you'd like Build a statically linked executable that does not depend on various dynamically linked .so libs

Describe alternatives you've considered None

Additional context

MikePopoloski commented 1 year ago

I'm open to this change but don't have the bandwidth to work on it myself. Feel free to open a PR with what you'd like to see.

sumn255 commented 1 year ago

I have the same requirement too.Now I modify CMakeLists.txt locally, don't know how to add a build option @idjordje in tools/CMakeLists.txt:line 8 -target_link_libraries(slang_driver PRIVATE slang::slang fmt::fmt) +target_link_libraries(slang_driver PRIVATE slang::slang fmt::fmt -static) line 13 -target_link_libraries(rewriter PRIVATE slang::slang) +target_link_libraries(rewriter PRIVATE slang::slang -static) in tools/tidy/CMakeLists.txt: line 9 -target_link_libraries(slang_tidy PRIVATE slang::slang fmt::fmt) +target_link_libraries(slang_tidy PRIVATE slang::slang fmt::fmt -static)

furkanusta commented 1 year ago

You can build statically, without any modifications

cmake 
  -DBUILD_SHARED_LIBS=OFF 
  -DCMAKE_EXE_LINKER_FLAGS=-static 
  -DCMAKE_FIND_LIBRARY_SUFFIXES=.a
  ../

If you already have fmt in your system you might also need -DCMAKE_DISABLE_FIND_PACKAGE_fmt=ON so that it is pulled via FetchContent

MikePopoloski commented 1 year ago

If this is as simple as setting some cmake command line flags then we can probably close this issue? @idjordje can you confirm?

idjordje commented 1 year ago

I’ve tried suggested command line switches and they produce statically linked executable that can be copied to other Unix systems.

@mikepopolski your call if you want to modify documentation saying “hey btw use these additional switches” or modify the make files to have one clean switch for all files. Seems executables in tools directory are built separately from main slang executable

-Ivan

On Tue, Apr 4, 2023 at 6:51 AM Michael Popoloski @.***> wrote:

If this is as simple as setting some cmake command line flags then we can probably close this issue? @idjordje https://github.com/idjordje can you confirm?

— Reply to this email directly, view it on GitHub https://github.com/MikePopoloski/slang/issues/736#issuecomment-1496012943, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAROHHJYPBYJ2RGACGCAJG3W7QRNZANCNFSM6AAAAAAWMTZC7I . You are receiving this because you were mentioned.Message ID: @.***>

idjordje commented 1 year ago

Btw if you decide on one clean switch for all executables I am fine with providing you with PR

-Ivan

On Tue, Apr 4, 2023 at 8:28 AM Ivan Djordjevic @.***> wrote:

I’ve tried suggested command line switches and they produce statically linked executable that can be copied to other Unix systems.

@mikepopolski your call if you want to modify documentation saying “hey btw use these additional switches” or modify the make files to have one clean switch for all files. Seems executables in tools directory are built separately from main slang executable

-Ivan

On Tue, Apr 4, 2023 at 6:51 AM Michael Popoloski @.***> wrote:

If this is as simple as setting some cmake command line flags then we can probably close this issue? @idjordje https://github.com/idjordje can you confirm?

— Reply to this email directly, view it on GitHub https://github.com/MikePopoloski/slang/issues/736#issuecomment-1496012943, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAROHHJYPBYJ2RGACGCAJG3W7QRNZANCNFSM6AAAAAAWMTZC7I . You are receiving this because you were mentioned.Message ID: @.***>

MikePopoloski commented 1 year ago

Sorry, what exactly are you asking for with "one clean switch"? As far as I know, the CMAKE_ arguments you pass to cmake apply to all targets that get built, so I'm not sure why you're having trouble with the slang executable vs the tools.

In general there's an almost unlimited number of flags someone might want to build with to customize the build, so I'm hesitant to enshrine this particular one unless a large number of people need exactly this. If you want something more convenient for your local build you should look into using a CMakeUserPresets file, which can let you wrap up flags like this in a locally maintainable file.

idjordje commented 1 year ago

Presets will work, you can close this issue.

-Ivan

From: Michael Popoloski @.> Sent: Wednesday, April 5, 2023 2:41 PM To: MikePopoloski/slang @.> Cc: idjordje @.>; Mention @.> Subject: Re: [MikePopoloski/slang] Option to create executable that does not have dependency on shared objects of the OS (Issue #736)

Sorry, what exactly are you asking for with "one clean switch"? As far as I know, the CMAKE_ arguments you pass to cmake apply to all targets that get built, so I'm not sure why you're having trouble with the slang executable vs the tools.

In general there's an almost unlimited number of flags someone might want to build with to customize the build, so I'm hesitant to enshrine this particular one unless a large number of people need exactly this. If you want something more convenient for your local build you should look into using a CMakeUserPresets file, which can let you wrap up flags like this in a locally maintainable file.

— Reply to this email directly, view it on GitHub https://github.com/MikePopoloski/slang/issues/736#issuecomment-1498195404 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AAROHHLROXXCECVGDPHK2J3W7XRGXANCNFSM6AAAAAAWMTZC7I . You are receiving this because you were mentioned. https://github.com/notifications/beacon/AAROHHMAF2CRUMPFHN2JLA3W7XRGXA5CNFSM6AAAAAAWMTZC7KWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTSZJSS4Y.gif Message ID: @. @.> >