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: deprecate mk-deb.sh mk-tar.sh and use make targets instead #2644

Merged
merged 1 commit into from
Oct 19, 2023

Conversation

charlie0129
Copy link
Contributor

@charlie0129 charlie0129 commented Jul 23, 2023

What problem does this PR solve?

Closes #2024

What is changed and how it works?

Major changes:

  • Deprecate mk-deb.sh and mk-tar.sh.
  • Use make targets instead: make <deb|tar> [options]
    • make tar dep=1
    • make deb release=0 dep=0

The original version builds on the host. I have to make heavy changes to the script to adapt to the new containerized build system. Now all build process should fit in the new containerized manner, i.e., using docker build conatiner, just like make build.

Minor changes:

  • Makefile of etcdclient has been improved to avoid unnecessary rebuilds and clones. It should be faster when building depencencies after the first time.
  • Allow multiple dirs in only like make xxx only=src/*,tools/*, instead of just one.
  • Allow specifying custom build options on util/build_in_image.sh
  • Common docker-related arguments have been put into docker_opts.sh
  • Made scripts in util/* executable.

Side effects(Breaking backward compatibility? Performance regression?):

The build result should be the same, to the best of my knowledge. I have tested it on a bare machine.

Documents that are affected by this change has been updated.

Check List

  • Relevant documentation/comments is changed or added
  • I acknowledge that all my contributions will be made under the project's license

@charlie0129
Copy link
Contributor Author

cicheck

1 similar comment
@wuhongsong
Copy link
Contributor

cicheck

@Cyber-SiKu
Copy link
Contributor

There is a problem with mk-tar now, you can fix it:
Compile the project first, and then compile curvefs_python. When the following statement is executed, some binary files will not be found. For example here:

curve/mk-tar.sh

Line 227 in 4a0372b

cp ./bazel-bin/src/mds/main/curvemds build/curve/curve-mds/bin/curve-mds

The cause is this:
In a certain change, the code for compiling the entire project was changed to the following:

curve/mk-tar.sh

Line 175 in 4a0372b

make build stor=bs release=0 dep=1 only=src/*

But compiling curvefs_python is directly using bazel.

curve/mk-tar.sh

Lines 108 to 119 in 4a0372b

if [ "$1" = "release" ]; then
bazel build curvefs_python:curvefs --copt -DHAVE_ZLIB=1 --copt -O2 -s \
--define=with_glog=true --define=libunwind=true --copt -DGFLAGS_NS=google \
--copt -Wno-error=format-security --copt -DUSE_BTHREAD_MUTEX --linkopt \
-L${dir}/curvefs_python/tmplib/ --copt -DCURVEVERSION=${curve_version} \
${bazelflags}
else
bazel build curvefs_python:curvefs --copt -DHAVE_ZLIB=1 --compilation_mode=dbg -s \
--define=with_glog=true --define=libunwind=true --copt -DGFLAGS_NS=google \
--copt -Wno-error=format-security --copt -DUSE_BTHREAD_MUTEX --linkopt \
-L${dir}/curvefs_python/tmplib/ --copt -DCURVEVERSION=${curve_version} \
${bazelflags}

The inconsistency of the compilation parameters caused bazel-bin to establish a new soft link. There is no corresponding binary file under the new soft link.

@wuhongsong
Copy link
Contributor

@charlie0129 continue?

@charlie0129
Copy link
Contributor Author

Yes, I am going to fix that. The build script changed to use docker builder instead before I was able to make changes so I am adapting my script to use the new method.

@charlie0129
Copy link
Contributor Author

Hi @Cyber-SiKu How can I build curvefs_python using the new util/build.sh script, if we want to avoid using bazel directly?

@Cyber-SiKu
Copy link
Contributor

@charlie0129 You can see how the script does it.

@charlie0129
Copy link
Contributor Author

charlie0129 commented Aug 22, 2023

@Cyber-SiKu Most build procedure is now done. But one problem, I was only able to compile /curvefs_python/libcurvefs.a, not a .so lib using make build only=curvefs_python/curvefs (with appropriate linker options to curvefs_python/tmplib).

PS: The old build command (using bazel directly) is not working in the new docker build container. The error is:

src/client/iomanager4chunk.cpp:62:59: error: 'new' of type 'curve::client::IOTracker' with extended alignment 64 [-Werror=aligned-new=]
   62 |     IOTracker* temp = new IOTracker(this, &mc_, scheduler_);

@wuhongsong
Copy link
Contributor

@Cyber-SiKu

@Cyber-SiKu
Copy link
Contributor

Most build procedure is now done. But one problem, I was only able to compile /curvefs_python/libcurvefs.a, not a .so lib using make build only=curvefs_python/curvefs (with appropriate linker options to curvefs_python/tmplib).

PS: The old build command (using bazel directly) is not working in the new docker build container. The error is:

This is related to the gcc version, please add --config=gcc7-later when compiling bazel

@charlie0129
Copy link
Contributor Author

cicheck

@charlie0129
Copy link
Contributor Author

Hi, @Cyber-SiKu the script now works fine for me. What do you think? Is there any problems?

@Cyber-SiKu
Copy link
Contributor

good job!

@Cyber-SiKu
Copy link
Contributor

Please add some output, how to compile, and screenshots of successful compilation.

@Cyber-SiKu
Copy link
Contributor

cicheck

@charlie0129
Copy link
Contributor Author

charlie0129 commented Sep 14, 2023

Please add some output, how to compile, and screenshots of successful compilation.

How to compile:

  • install required dependencies, like docker, git, and etc. I use docker in the script to do subsequent compilation so no build toolchain is required on the host machine.
  • clone this branch and cd into it.
  • make tar dep=1 or make deb. dep=1 is required for the first run to build dependencies. It should take several minutes on a 64 core machine to do a full compile.
  • Build output should be in the current dir.

Screenshots:

Compiling
SCR-20230914-mwzw

Successful compilation
image

Artifacts
image

@@ -27,7 +38,7 @@ intall-go:

install-etcdclient:
mkdir -p $(pwd)/tmp/gosrc/src/go.etcd.io
cd $(pwd)/tmp/gosrc/src/go.etcd.io && git clone --branch v3.4.0 https://gitee.com/mirrors/etcd
cd $(pwd)/tmp/gosrc/src/go.etcd.io && git clone --branch v3.4.0 --depth=1 https://gitee.com/mirrors/etcd
Copy link
Contributor

Choose a reason for hiding this comment

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

What does --depth=1 do?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It will only clone the most recent commit, rather than the entire history. Since we will certainly not use the commit history when we are building etcd, ignoring the commit history will make it faster to clone.

util/build.sh Outdated
Comment on lines 88 to 93
-w /curve \
--user $(id -u ${USER}):$(id -g ${USER}) \
-v $(pwd):/curve \
-v ${HOME}:${HOME} \
-v /etc/passwd:/etc/passwd:ro \
-v /etc/group:/etc/group:ro \
-v /etc/shadow:/etc/shadow:ro \
-e BUILD_OPTS="${BUILD_OPTS}" \
--privileged \
opencurvedocker/curve-base:build-$g_os \
bash util/build_in_image.sh "$@"
Copy link
Contributor

Choose a reason for hiding this comment

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

Can the docker related stuff be organized and put in util/docker.sh? for reference only

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Of course. I will add to docker.sh

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean we just add the docker-related stuff to util/docker.sh without calling them? Or we add and call it from other scripts?

I have assumed the latter one. After some investigation, I think I will need to edit docker.sh to an extent that I think is too much to make it flexible enough to call in other scripts. Provided it already have some useful contents, maybe I will leave docker.sh as is.

Copy link
Contributor

Choose a reason for hiding this comment

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

Do you mean we just add the docker-related stuff to util/docker.sh without calling them? Or we add and call it from other scripts?

I have assumed the latter one. After some investigation, I think I will need to edit docker.sh to an extent that I think is too much to make it flexible enough to call in other scripts. Provided it already have some useful contents, maybe I will leave docker.sh as is.

the latter one.What you write now can also be used, but the latter one is more general and better.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi I organized common docker-related arguments into a separate file called docker_opts.sh. It should be easier to manage all docker things from one place now.

I only extracted common docker-related arguments, so other scripts can source them and make modifications freely. The reason why I did not use util/docker.sh is that if I edit it to be flexible engough to be used in other scripts, I am afraid to break other things that are already using this script.

Makefile Outdated Show resolved Hide resolved
util/build.sh Show resolved Hide resolved
util/package.sh Outdated Show resolved Hide resolved
@charlie0129
Copy link
Contributor Author

charlie0129 commented Sep 25, 2023

@Cyber-SiKu hi, are there any further issues on this pr?

@SeanHai
Copy link
Contributor

SeanHai commented Sep 27, 2023

LGTM!

@Cyber-SiKu
Copy link
Contributor

cicheck

Copy link
Contributor

@Cyber-SiKu Cyber-SiKu left a comment

Choose a reason for hiding this comment

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

LGTM

@Cyber-SiKu
Copy link
Contributor

cicheck

1 similar comment
@Cyber-SiKu
Copy link
Contributor

cicheck

@charlie0129
Copy link
Contributor Author

@Cyber-SiKu Is there something in my code that is causing the CI to fail? a bit confused

@SeanHai
Copy link
Contributor

SeanHai commented Oct 11, 2023

cicheck

1 similar comment
@charlie0129
Copy link
Contributor Author

cicheck

@charlie0129 charlie0129 force-pushed the deprecate-mk-tar-deb branch 4 times, most recently from 2d189c4 to fb8cd73 Compare October 11, 2023 05:58
@charlie0129
Copy link
Contributor Author

cicheck

7 similar comments
@charlie0129
Copy link
Contributor Author

cicheck

@SeanHai
Copy link
Contributor

SeanHai commented Oct 11, 2023

cicheck

@SeanHai
Copy link
Contributor

SeanHai commented Oct 11, 2023

cicheck

@charlie0129
Copy link
Contributor Author

cicheck

@SeanHai
Copy link
Contributor

SeanHai commented Oct 17, 2023

cicheck

@SeanHai
Copy link
Contributor

SeanHai commented Oct 17, 2023

cicheck

@SeanHai
Copy link
Contributor

SeanHai commented Oct 17, 2023

cicheck

Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com>
@charlie0129
Copy link
Contributor Author

cicheck

@SeanHai SeanHai merged commit 7aa35ee into opencurve:master Oct 19, 2023
5 checks passed
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.

[compile] Merge the two scripts mk-tar.sh and mk-deb.sh
4 participants