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

Add a cmake option to let users build libraries only #14607

Closed

Conversation

junaire
Copy link
Contributor

@junaire junaire commented Oct 13, 2023

When Solidity is used as a series of libraries, we don't need to build those command line tools. Not only because it's waste of time, but it also prevents linking libboostoptions.a, which can cause some issues under certain circumstances.

When Solidity is used as a series of libraries, we don't need to build
those command line tools. Not only because it's waste of time, but it
also prevents linking libboostoptions.a, which can cause some issues
under certain circumstances.

Signed-off-by: Jun Zhang <jun@junz.org>
@github-actions
Copy link

Thank you for your contribution to the Solidity compiler! A team member will follow up shortly.

If you haven't read our contributing guidelines and our review checklist before, please do it now, this makes the reviewing process and accepting your contribution smoother.

If you have any questions or need our help, feel free to post them in the PR or talk to us directly on the #solidity-dev channel on Matrix.

@@ -37,6 +37,7 @@ option(SOLC_STATIC_STDLIBS "Link solc against static versions of libgcc and libs
option(STRICT_Z3_VERSION "Use the latest version of Z3" ON)
option(PEDANTIC "Enable extra warnings and pedantic build flags. Treat all warnings as errors." ON)
option(PROFILE_OPTIMIZER_STEPS "Output performance metrics for the optimiser steps." OFF)
option(BUILD_LIBS_ONLY "Only build Solidity libraries and discard command line tools." OFF)
Copy link
Member

@cameel cameel Oct 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we really need such an option. That's the functionality you get out of the box as a part of the underlying build system. For example if you're only interested in liblangutil and libsmtutil, you can simply invoke make like this:

make langutil smtutil

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we really need such an option. That's the functionality you get out of the box as a part of the underlying build system. For example if you're only interested in liblangutil and libsmtutil, you can simply invoke make like this:

make langutil smtutil

Your comments only make sense if you are working on the Solidity compiler directly. In my case, I'm using Solidity as a third-party library, so in my CMakeLists.txt, I have something like:

# Disable Solidity tests to speed up the build.
set(TESTS OFF)
# Disable Z3 SMT solver to avoid dependency issues.
set(USE_Z3 OFF)
message(STATUS "Start fetching Solidity libraries")
FetchContent_Declare(
  solidity
  GIT_REPOSITORY https://github.com/ethereum/solidity.git
  GIT_TAG origin/v0.8.21
)

add_library(my_downstream_app ${sources})

target_link_libraries(
    my_downstream_app
    PRIVATE
    solidity)

In this case, you cannot simply use make to choose the subtarget because they all belong to solidity IIUC.

@junaire
Copy link
Contributor Author

junaire commented Oct 14, 2023

What I really want is stripping those libboostxxx.a when linking my program, so I added this option to exclude targets that depend on those libraries. However, I still observe these .a show up after this change... So yeah it's not what I want so I'm gonna close this. Thank you!

@junaire junaire closed this Oct 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants