google / differential-privacy

Google's differential privacy libraries.
Apache License 2.0
3.02k stars 346 forks source link

Build fails on Mac #125

Closed jameskyle closed 1 year ago

jameskyle commented 2 years ago

bazel-4.1.0 build ... from the java workspace produces the following build errors

MacOS 12.5.1 Processor: 2.4 GHz 8-Core Intel Core i9

To suppress this warning, remove the --frames option and avoid the use of frames.
/var/folders/6d/dh6ysjd97qnd9dmbtklkbvxm0000gn/T/unpacked-sources11742020754130480421/com/google/privacy/differentialprivacy/AutoValue_BoundedQuantiles_Params.java:3: error: cannot find symbol
import javax.annotation.Generated;
                       ^
  symbol:   class Generated
  location: package javax.annotation
/var/folders/6d/dh6ysjd97qnd9dmbtklkbvxm0000gn/T/unpacked-sources11742020754130480421/com/google/privacy/differentialprivacy/AutoValue_BoundedQuantiles_Params.java:6: error: cannot find symbol
@Generated("com.google.auto.value.processor.AutoValueProcessor")
 ^
  symbol: class Generated
/var/folders/6d/dh6ysjd97qnd9dmbtklkbvxm0000gn/T/unpacked-sources11742020754130480421/com/google/privacy/differentialprivacy/AutoValue_BoundedSum_Params.java:3: error: cannot find symbol
import javax.annotation.Generated;
                       ^
  symbol:   class Generated
  location: package javax.annotation
/var/folders/6d/dh6ysjd97qnd9dmbtklkbvxm0000gn/T/unpacked-sources11742020754130480421/com/google/privacy/differentialprivacy/AutoValue_BoundedSum_Params.java:6: error: cannot find symbol
@Generated("com.google.auto.value.processor.AutoValueProcessor")
 ^
  symbol: class Generated
/var/folders/6d/dh6ysjd97qnd9dmbtklkbvxm0000gn/T/unpacked-sources11742020754130480421/com/google/privacy/differentialprivacy/AutoValue_BoundedMean_Params.java:3: error: cannot find symbol
import javax.annotation.Generated;
                       ^
  symbol:   class Generated
  location: package javax.annotation
/var/folders/6d/dh6ysjd97qnd9dmbtklkbvxm0000gn/T/unpacked-sources11742020754130480421/com/google/privacy/differentialprivacy/AutoValue_BoundedMean_Params.java:6: error: cannot find symbol
@Generated("com.google.auto.value.processor.AutoValueProcessor")
 ^
  symbol: class Generated
/var/folders/6d/dh6ysjd97qnd9dmbtklkbvxm0000gn/T/unpacked-sources11742020754130480421/com/google/privacy/differentialprivacy/AutoValue_Count_Params.java:3: error: cannot find symbol
import javax.annotation.Generated;
                       ^
  symbol:   class Generated
  location: package javax.annotation
/var/folders/6d/dh6ysjd97qnd9dmbtklkbvxm0000gn/T/unpacked-sources11742020754130480421/com/google/privacy/differentialprivacy/AutoValue_Count_Params.java:6: error: cannot find symbol
@Generated("com.google.auto.value.processor.AutoValueProcessor")
 ^
  symbol: class Generated
/var/folders/6d/dh6ysjd97qnd9dmbtklkbvxm0000gn/T/unpacked-sources11742020754130480421/com/google/privacy/differentialprivacy/AutoValue_BoundedQuantiles_IndexAndRank.java:3: error: cannot find symbol
import javax.annotation.Generated;
                       ^
  symbol:   class Generated
  location: package javax.annotation
/var/folders/6d/dh6ysjd97qnd9dmbtklkbvxm0000gn/T/unpacked-sources11742020754130480421/com/google/privacy/differentialprivacy/AutoValue_BoundedQuantiles_IndexAndRank.java:5: error: cannot find symbol
@Generated("com.google.auto.value.processor.AutoValueProcessor")
 ^
  symbol: class Generated
/var/folders/6d/dh6ysjd97qnd9dmbtklkbvxm0000gn/T/unpacked-sources11742020754130480421/com/google/privacy/differentialprivacy/AutoValue_ConfidenceInterval.java:3: error: cannot find symbol
import javax.annotation.Generated;
                       ^
  symbol:   class Generated
  location: package javax.annotation
/var/folders/6d/dh6ysjd97qnd9dmbtklkbvxm0000gn/T/unpacked-sources11742020754130480421/com/google/privacy/differentialprivacy/AutoValue_ConfidenceInterval.java:5: error: cannot find symbol
@Generated("com.google.auto.value.processor.AutoValueProcessor")
 ^
  symbol: class Generated
12 errors
1 warning
jameskyle commented 2 years ago

Checking bazel info, looks like it's using Java 11 for the sdk. Seems a likely candidate for this issue.

JAVA_HOME is set for Java 8. So looking into how to get bazel to pick up this sdk for the build.

azel-bin: /private/var/tmp/_bazel_jkyle/078298ed9896e20c0b15e3053f915399/execroot/com_google_java_differential_privacy/bazel-out/darwin-fastbuild/bin
bazel-genfiles: /private/var/tmp/_bazel_jkyle/078298ed9896e20c0b15e3053f915399/execroot/com_google_java_differential_privacy/bazel-out/darwin-fastbuild/bin
bazel-testlogs: /private/var/tmp/_bazel_jkyle/078298ed9896e20c0b15e3053f915399/execroot/com_google_java_differential_privacy/bazel-out/darwin-fastbuild/testlogs
character-encoding: file.encoding = ISO-8859-1, defaultCharset = ISO-8859-1
command_log: /private/var/tmp/_bazel_jkyle/078298ed9896e20c0b15e3053f915399/command.log
committed-heap-size: 125MB
execution_root: /private/var/tmp/_bazel_jkyle/078298ed9896e20c0b15e3053f915399/execroot/com_google_java_differential_privacy
gc-count: 108
gc-time: 2295ms
install_base: /var/tmp/_bazel_jkyle/install/d07238c5957d0addf241b6be07f3c14b
java-home: /private/var/tmp/_bazel_jkyle/install/d07238c5957d0addf241b6be07f3c14b/embedded_tools/jdk
java-runtime: OpenJDK Runtime Environment (build 11.0.6+10-LTS) by Azul Systems, Inc.
java-vm: OpenJDK 64-Bit Server VM (build 11.0.6+10-LTS, mixed mode) by Azul Systems, Inc.
max-heap-size: 17179MB
output_base: /private/var/tmp/_bazel_jkyle/078298ed9896e20c0b15e3053f915399
output_path: /private/var/tmp/_bazel_jkyle/078298ed9896e20c0b15e3053f915399/execroot/com_google_java_differential_privacy/bazel-out
package_path: %workspace%
release: release 4.1.0
repository_cache: /var/tmp/_bazel_jkyle/cache/repos/v1
server_log: /private/var/tmp/_bazel_jkyle/078298ed9896e20c0b15e3053f915399/java.log.ip-192-168-0-2.jkyle.log.java.20220901-144136.18665
server_pid: 18665
used-heap-size: 63MB
workspace: /Users/jkyle/IdeaProjects/differential-privacy/java
jameskyle commented 2 years ago

Ok, bazel info says it's using java11. But, if I execute the following it builds successfully

bazel-4.1.0 build --java_toolchain=@bazel_tools//tools/jdk:toolchain_java11 ...

But if I do this, it fails with the error above

bazel-4.1.0 build --java_toolchain=@bazel_tools//tools/jdk:toolchain_java8 ...

I know there were changes in how @Generated is managed between java 8 and 11, so this is probably a consequence of that. Looking for a workaround.

jameskyle commented 2 years ago

build succeeds with java 17.

jameskyle commented 2 years ago

Ohh, k. I found a patch for the Gerrit Build that seemed to describe the same behavior I was seeing. And I looked at the executed javadoc command and it was referencing the host binary.

So I installed java 17, set that to JAVA_HOME, then ran the build with

bazel-4.1.0 build --java_toolchain=@bazel_tools//tools/jdk:toolchain_java8 ...

This succeeded. I verified the byte code by checking a class file

% file SecureNoiseMath.class
SecureNoiseMath.class: compiled Java class data, version 52.0 (Java 1.8)

So this looks good, maybe just needs a documentation update for building with 1.8?

dibakch commented 2 years ago

Thanks for filing this issue and also figuring out a solution!

I wasn't able to reproduce this issue on Linux. However, we just updated the Auto Value and other dependencies for Java. Could you kindly check if this is still an issue for the current head?

Thanks :)

jameskyle commented 1 year ago

Looks like it's resolve don HEAD!