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

chore: remove aztec compile time feature flag #3596

Merged
merged 45 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
6f6217f
create a namespaced API for macros
kevaundray Nov 26, 2023
1212b44
remove aztec specific error variants
kevaundray Nov 26, 2023
8373541
remove aztec feature flag from frontend by allowing arbitrary macro p…
kevaundray Nov 26, 2023
f2b128e
fix test
kevaundray Nov 26, 2023
413260c
add aztec_macro crate
kevaundray Nov 26, 2023
8282ffe
remove aztec feature flag and code from noirc_frontend
kevaundray Nov 26, 2023
927a2a3
add aztec feature flag to noirc_driver
kevaundray Nov 26, 2023
b2fb79a
modify yml feature flags
kevaundray Nov 26, 2023
f3fa65f
clippy fix
kevaundray Nov 26, 2023
7afdc45
use slice of trait objects when there are no macro processors
kevaundray Nov 26, 2023
7df00c7
replace opaque type with trait object in function signature
kevaundray Nov 26, 2023
7c9198f
fmt
kevaundray Nov 26, 2023
e6b4b89
temporarily coerce the type system -- a clone here would likely not b…
kevaundray Nov 26, 2023
89b4678
fmt
kevaundray Nov 26, 2023
00136a1
use vec instead of slice and clone the pointers to vtable (references…
kevaundray Nov 26, 2023
cf11ad9
fmt
kevaundray Nov 26, 2023
a925d8d
remove extraneous & in test
kevaundray Nov 26, 2023
546020d
remove aztec feature flag
kevaundray Nov 27, 2023
958e11f
remove aztec builds from CI workflow
kevaundray Nov 27, 2023
0684bf4
Update compiler/noirc_driver/Cargo.toml
TomAFrench Nov 27, 2023
26559c3
remove duplicated code
kevaundray Nov 28, 2023
c7dd9b9
Merge branch 'master' into kw/create-api-for-macros
kevaundray Nov 28, 2023
7d3f0e1
Merge branch 'kw/create-api-for-macros' into kw/remove-aztec-feature-…
kevaundray Nov 28, 2023
4b64a69
Merge remote-tracking branch 'origin/master' into kw/remove-aztec-fea…
kevaundray Nov 28, 2023
d6ebf4f
add aztec macros flag for compiling in typescript
kevaundray Nov 28, 2023
8c7a7c4
cargo fmt --all
kevaundray Nov 29, 2023
8beb276
default to enabling the macro on lsp run
kevaundray Nov 29, 2023
79f9afc
Merge remote-tracking branch 'origin/master' into kw/remove-aztec-fea…
kevaundray Nov 30, 2023
2c4e84b
fix test
kevaundray Nov 30, 2023
f5060a2
fmt
kevaundray Nov 30, 2023
a849a11
Merge branch 'master' into kw/remove-aztec-feature-flag
kevaundray Nov 30, 2023
5746d40
enable aztec macro via an environment variable
kevaundray Nov 30, 2023
1aa2206
set the aztec macro based on environment variable for lsp
kevaundray Nov 30, 2023
58fe17b
add missing args
kevaundray Dec 1, 2023
14d846b
lint fix
kevaundray Dec 1, 2023
43a8561
Merge branch 'master' into kw/remove-aztec-feature-flag
kevaundray Dec 5, 2023
d436b0d
Merge branch 'master' into kw/remove-aztec-feature-flag
TomAFrench Dec 11, 2023
f7a8f9f
chore: fix missing arg
TomAFrench Dec 12, 2023
8f99af1
Empty commit to signal me making changes
kevaundray Dec 12, 2023
7f4a1f9
remove threading of aztec macros flag
kevaundray Dec 12, 2023
cb69179
clippy
kevaundray Dec 12, 2023
97ed2fb
revert changes
kevaundray Dec 12, 2023
9d0e9fd
compile no longer needs extra parameter
kevaundray Dec 12, 2023
6c266dc
add disable_macros flag
kevaundray Dec 12, 2023
3bb1c2e
add code to handle disabling macros
kevaundray Dec 12, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 0 additions & 45 deletions .github/workflows/build-aztec-feature-flag.yml

This file was deleted.

5 changes: 0 additions & 5 deletions .github/workflows/publish-es-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ jobs:
nix-cache-name: "noir"
cachix-auth-token: ${{ secrets.CACHIXAUTHTOKEN }}

- name: Enable aztec features
if: ${{ inputs.npm-tag == 'aztec' }}
run: |
echo $'\n'"default = [\"aztec\"]"$'\n' >> compiler/noirc_driver/Cargo.toml

- name: Build wasm package
run: |
nix build -L .#noir_wasm
Expand Down
5 changes: 1 addition & 4 deletions compiler/noirc_driver/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,4 @@ fm.workspace = true
serde.workspace = true
fxhash.workspace = true

aztec_macros ={path = "../../aztec_macros", optional = true}

[features]
aztec = ["aztec_macros"]
aztec_macros = { path = "../../aztec_macros" }
18 changes: 12 additions & 6 deletions compiler/noirc_driver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ pub struct CompileOptions {
/// Suppress warnings
#[arg(long, conflicts_with = "deny_warnings")]
pub silence_warnings: bool,

/// Enables the aztec macro preprocessor
#[arg(long, hide = true)]
pub aztec_macro: bool,
kevaundray marked this conversation as resolved.
Show resolved Hide resolved
}

/// Helper type used to signify where only warnings are expected in file diagnostics
Expand Down Expand Up @@ -121,11 +125,12 @@ pub fn check_crate(
context: &mut Context,
crate_id: CrateId,
deny_warnings: bool,
enable_aztec_macro: bool,
) -> CompilationResult<()> {
#[cfg(not(feature = "aztec"))]
let macros: Vec<&dyn MacroProcessor> = Vec::new();
#[cfg(feature = "aztec")]
let macros = vec![&aztec_macros::AztecMacro as &dyn MacroProcessor];
let mut macros: Vec<&dyn MacroProcessor> = Vec::new();
if enable_aztec_macro {
macros.push(&aztec_macros::AztecMacro as &dyn MacroProcessor);
}

let mut errors = vec![];
let diagnostics = CrateDefMap::collect_defs(crate_id, context, macros);
Expand Down Expand Up @@ -161,7 +166,8 @@ pub fn compile_main(
cached_program: Option<CompiledProgram>,
force_compile: bool,
) -> CompilationResult<CompiledProgram> {
let (_, mut warnings) = check_crate(context, crate_id, options.deny_warnings)?;
let (_, mut warnings) =
check_crate(context, crate_id, options.deny_warnings, options.aztec_macro)?;

let main = context.get_main_function(&crate_id).ok_or_else(|| {
// TODO(#2155): This error might be a better to exist in Nargo
Expand Down Expand Up @@ -194,7 +200,7 @@ pub fn compile_contract(
crate_id: CrateId,
options: &CompileOptions,
) -> CompilationResult<CompiledContract> {
let (_, warnings) = check_crate(context, crate_id, options.deny_warnings)?;
let (_, warnings) = check_crate(context, crate_id, options.deny_warnings, options.aztec_macro)?;

// TODO: We probably want to error if contracts is empty
let contracts = context.get_all_contracts(&crate_id);
Expand Down
2 changes: 2 additions & 0 deletions tooling/lsp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ pub struct LspState {
root_path: Option<PathBuf>,
client: ClientSocket,
solver: WrapperSolver,
enable_aztec_macro: bool,
input_files: HashMap<String, String>,
}

Expand All @@ -55,6 +56,7 @@ impl LspState {
client: client.clone(),
root_path: None,
solver: WrapperSolver(Box::new(solver)),
enable_aztec_macro: false,
input_files: HashMap::new(),
}
}
Expand Down
9 changes: 5 additions & 4 deletions tooling/lsp/src/notifications/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,11 @@ pub(super) fn on_did_save_text_document(
.flat_map(|package| -> Vec<Diagnostic> {
let (mut context, crate_id) = prepare_package(package, Box::new(get_non_stdlib_asset));

let file_diagnostics = match check_crate(&mut context, crate_id, false) {
Ok(((), warnings)) => warnings,
Err(errors_and_warnings) => errors_and_warnings,
};
let file_diagnostics =
match check_crate(&mut context, crate_id, false, state.enable_aztec_macro) {
Ok(((), warnings)) => warnings,
Err(errors_and_warnings) => errors_and_warnings,
};

// We don't add test headings for a package if it contains no `#[test]` functions
if let Some(tests) = get_package_tests_in_crate(&context, &crate_id, &package.name) {
Expand Down
2 changes: 1 addition & 1 deletion tooling/lsp/src/requests/code_lens_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ fn on_code_lens_request_inner(
let (mut context, crate_id) = prepare_package(package, Box::new(get_non_stdlib_asset));
// We ignore the warnings and errors produced by compilation for producing code lenses
// because we can still get the test functions even if compilation fails
let _ = check_crate(&mut context, crate_id, false);
let _ = check_crate(&mut context, crate_id, false, state.enable_aztec_macro);

let fm = &context.file_manager;
let files = fm.as_file_map();
Expand Down
4 changes: 3 additions & 1 deletion tooling/lsp/src/requests/profile_run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,15 @@ fn on_profile_run_request_inner(
let is_opcode_supported = |_opcode: &Opcode| true;
let np_language = Language::PLONKCSat { width: 3 };

let compile_options =
CompileOptions { aztec_macro: state.enable_aztec_macro, ..Default::default() };
let (compiled_programs, compiled_contracts) = nargo::ops::compile_workspace(
&workspace,
&binary_packages,
&contract_packages,
np_language,
is_opcode_supported,
&CompileOptions::default(),
&compile_options,
)
.map_err(|err| ResponseError::new(ErrorCode::REQUEST_FAILED, err))?;

Expand Down
2 changes: 1 addition & 1 deletion tooling/lsp/src/requests/test_run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ fn on_test_run_request_inner(
match workspace.into_iter().next() {
Some(package) => {
let (mut context, crate_id) = prepare_package(package, Box::new(get_non_stdlib_asset));
if check_crate(&mut context, crate_id, false).is_err() {
if check_crate(&mut context, crate_id, false, state.enable_aztec_macro).is_err() {
let result = NargoTestRunResult {
id: params.id.clone(),
result: "error".to_string(),
Expand Down
2 changes: 1 addition & 1 deletion tooling/lsp/src/requests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ fn on_tests_request_inner(
let (mut context, crate_id) = prepare_package(package, Box::new(get_non_stdlib_asset));
// We ignore the warnings and errors produced by compilation for producing tests
// because we can still get the test functions even if compilation fails
let _ = check_crate(&mut context, crate_id, false);
let _ = check_crate(&mut context, crate_id, false, state.enable_aztec_macro);

// We don't add test headings for a package if it contains no `#[test]` functions
get_package_tests_in_crate(&context, &crate_id, &package.name)
Expand Down
4 changes: 3 additions & 1 deletion tooling/nargo_cli/src/cli/check_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ fn check_package(package: &Package, compile_options: &CompileOptions) -> Result<
crate_id,
compile_options.deny_warnings,
compile_options.silence_warnings,
compile_options.aztec_macro,
)?;

if package.is_library() || package.is_contract() {
Expand Down Expand Up @@ -183,8 +184,9 @@ pub(crate) fn check_crate_and_report_errors(
crate_id: CrateId,
deny_warnings: bool,
silence_warnings: bool,
enable_aztec_macro: bool,
) -> Result<(), CompileError> {
let result = check_crate(context, crate_id, deny_warnings);
let result = check_crate(context, crate_id, deny_warnings, enable_aztec_macro);
super::compile_cmd::report_errors(
result,
&context.file_manager,
Expand Down
1 change: 1 addition & 0 deletions tooling/nargo_cli/src/cli/test_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ fn run_tests<S: BlackBoxFunctionSolver>(
crate_id,
compile_options.deny_warnings,
compile_options.silence_warnings,
compile_options.aztec_macro,
)?;

let test_functions = context.get_all_test_functions_in_crate_matching(&crate_id, test_name);
Expand Down
Loading