From 9e819d0963d5187f2bd3b0fef4c604f1646e66fb Mon Sep 17 00:00:00 2001 From: James Lent Date: Sun, 11 Oct 2015 00:12:25 -0400 Subject: [PATCH 1/2] Modify the way java static builds are done so that: 1) There is no need to download and install the compression libraries twice just to get access to their header files during the compile phase. 2) Ensure that the compression library headers files used during the compile phase are the same ones used to build the static library that is linked into the library. --- Makefile | 24 +++++++++++++++++------- java/crossbuild/build-linux-centos.sh | 4 +--- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index d9ad6572e..3e694efda 100644 --- a/Makefile +++ b/Makefile @@ -1035,19 +1035,22 @@ liblz4.a: cd lz4-r127/lib && make CFLAGS='-fPIC' all cp lz4-r127/lib/liblz4.a . -# A version of each $(LIBOBJECTS) compiled with -fPIC -java_libobjects = $(patsubst %,jl/%,$(LIBOBJECTS)) -CLEAN_FILES += jl +# A version of each $(LIBOBJECTS) compiled with -fPIC and a fixed set of static compression libraries +java_static_libobjects = $(patsubst %,jls/%,$(LIBOBJECTS)) +CLEAN_FILES += jls -$(java_libobjects): jl/%.o: %.cc - $(AM_V_CC)mkdir -p $(@D) && $(CXX) $(CXXFLAGS) -fPIC -c $< -o $@ $(COVERAGEFLAGS) +JAVA_STATIC_FLAGS = -DZLIB -DBZIP2 -DSNAPPY -DLZ4 +JAVA_STATIC_INCLUDES = -I./zlib-1.2.8 -I./bzip2-1.0.6 -I./snappy-1.1.1 -I./lz4-r127/lib -rocksdbjavastatic: $(java_libobjects) libz.a libbz2.a libsnappy.a liblz4.a +$(java_static_libobjects): jls/%.o: %.cc libz.a libbz2.a libsnappy.a liblz4.a + $(AM_V_CC)mkdir -p $(@D) && $(CXX) $(CXXFLAGS) $(JAVA_STATIC_FLAGS) $(JAVA_STATIC_INCLUDES) -fPIC -c $< -o $@ $(COVERAGEFLAGS) + +rocksdbjavastatic: $(java_static_libobjects) cd java;$(MAKE) javalib; rm -f ./java/target/$(ROCKSDBJNILIB) $(CXX) $(CXXFLAGS) -I./java/. $(JAVA_INCLUDE) -shared -fPIC \ -o ./java/target/$(ROCKSDBJNILIB) $(JNI_NATIVE_SOURCES) \ - $(java_libobjects) $(COVERAGEFLAGS) \ + $(java_static_libobjects) $(COVERAGEFLAGS) \ libz.a libbz2.a libsnappy.a liblz4.a $(JAVA_STATIC_LDFLAGS) cd java/target;strip -S -x $(ROCKSDBJNILIB) cd java;jar -cf target/$(ROCKSDB_JAR) HISTORY*.md @@ -1070,6 +1073,13 @@ rocksdbjavastaticpublish: rocksdbjavastaticrelease mvn gpg:sign-and-deploy-file -Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2/ -DrepositoryId=sonatype-nexus-staging -DpomFile=java/rocksjni.pom -Dfile=java/target/rocksdbjni-$(ROCKSDB_MAJOR).$(ROCKSDB_MINOR).$(ROCKSDB_PATCH)-osx.jar -Dclassifier=osx mvn gpg:sign-and-deploy-file -Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2/ -DrepositoryId=sonatype-nexus-staging -DpomFile=java/rocksjni.pom -Dfile=java/target/rocksdbjni-$(ROCKSDB_MAJOR).$(ROCKSDB_MINOR).$(ROCKSDB_PATCH).jar +# A version of each $(LIBOBJECTS) compiled with -fPIC +java_libobjects = $(patsubst %,jl/%,$(LIBOBJECTS)) +CLEAN_FILES += jl + +$(java_libobjects): jl/%.o: %.cc + $(AM_V_CC)mkdir -p $(@D) && $(CXX) $(CXXFLAGS) -fPIC -c $< -o $@ $(COVERAGEFLAGS) + rocksdbjava: $(java_libobjects) $(AM_V_GEN)cd java;$(MAKE) javalib; $(AM_V_at)rm -f ./java/target/$(ROCKSDBJNILIB) diff --git a/java/crossbuild/build-linux-centos.sh b/java/crossbuild/build-linux-centos.sh index 7fd8cfe76..2e8f81d94 100755 --- a/java/crossbuild/build-linux-centos.sh +++ b/java/crossbuild/build-linux-centos.sh @@ -1,9 +1,7 @@ #!/usr/bin/env bash # install all required packages for rocksdb that are available through yum ARCH=$(uname -i) -sudo yum -y install openssl java-1.7.0-openjdk-devel.$ARCH zlib zlib-devel bzip2 bzip2-devel -sudo yum -y install epel-release-5-4.noarch -sudo yum -y install snappy snappy-devel +sudo yum -y install openssl java-1.7.0-openjdk-devel.$ARCH # install gcc/g++ 4.8.2 via CERN (http://linux.web.cern.ch/linux/devtoolset/) sudo wget -O /etc/yum.repos.d/slc5-devtoolset.repo http://linuxsoft.cern.ch/cern/devtoolset/slc5-devtoolset.repo From 1ddd91cd2c48d555c8922c3fcae705d91518da9c Mon Sep 17 00:00:00 2001 From: dmittendorf Date: Mon, 12 Oct 2015 20:29:58 -0400 Subject: [PATCH 2/2] Fixed packaging of java crossbuild jar by forcing all compiled binaries to be output to the java/target directory. The uber crossbuild jar is then assembled within the java/target directory. --- Makefile | 2 +- java/RELEASE.md | 2 +- java/crossbuild/Vagrantfile | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 3e694efda..d4ccb0df8 100644 --- a/Makefile +++ b/Makefile @@ -1062,7 +1062,7 @@ rocksdbjavastatic: $(java_static_libobjects) rocksdbjavastaticrelease: rocksdbjavastatic cd java/crossbuild && vagrant destroy -f && vagrant up linux32 && vagrant halt linux32 && vagrant up linux64 && vagrant halt linux64 cd java;jar -cf target/$(ROCKSDB_JAR_ALL) HISTORY*.md - cd java;jar -uf target/$(ROCKSDB_JAR_ALL) librocksdbjni-*.so librocksdbjni-*.jnilib + cd java/target;jar -uf $(ROCKSDB_JAR_ALL) librocksdbjni-*.so librocksdbjni-*.jnilib cd java/target/classes;jar -uf ../$(ROCKSDB_JAR_ALL) org/rocksdb/*.class org/rocksdb/util/*.class rocksdbjavastaticpublish: rocksdbjavastaticrelease diff --git a/java/RELEASE.md b/java/RELEASE.md index 084460c88..cb9aaf987 100644 --- a/java/RELEASE.md +++ b/java/RELEASE.md @@ -15,7 +15,7 @@ Once you have these items, run this make command from RocksDB's root source dire This command will build RocksDB natively on OSX, and will then spin up two Vagrant Virtualbox Ubuntu images to build RocksDB for both 32-bit and 64-bit Linux. -You can find all native binaries and JARs in the java directory upon completion: +You can find all native binaries and JARs in the java/target directory upon completion: librocksdbjni-linux32.so librocksdbjni-linux64.so diff --git a/java/crossbuild/Vagrantfile b/java/crossbuild/Vagrantfile index 8a52b9261..21cce1201 100644 --- a/java/crossbuild/Vagrantfile +++ b/java/crossbuild/Vagrantfile @@ -20,7 +20,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| end config.vm.provision :shell, path: "build-linux-centos.sh" - config.vm.synced_folder "../", "/rocksdb-build" + config.vm.synced_folder "../target", "/rocksdb-build" config.vm.synced_folder "../..", "/rocksdb", type: "rsync" config.vm.boot_timeout = 1200 end