Anchorでmpl_token_metadataを使うと「conflicts with global allocator」エラー

現象

Anchorで mpl_token_metadata::pda::find_metadata_account を使ってMintアドレスをもとにMetadataアカウントを取得しようと思い、anchor testを実行すると以下のエラーが発生。

ターミナル:

% anchor test

 *  Executing task: anchor test 

BPF SDK: /Users/user/.local/share/solana/install/releases/1.10.8/solana-release/bin/sdk/bpf
cargo-build-bpf child: rustup toolchain list -v
cargo-build-bpf child: cargo +bpf build --target bpfel-unknown-unknown --release
   Compiling myanc v0.1.0 (/Users/user/Desktop/temp/myanc/programs/myanc)
error: the `#[global_allocator]` in this crate conflicts with global allocator in: mpl_token_metadata

error: could not compile `myanc` due to previous error
 *  Terminal will be reused by tasks, press any key to close it. 

lib.rs:

use anchor_lang::prelude::*;
use solana_program::pubkey::Pubkey;
use mpl_token_metadata::pda::find_metadata_account;

declare_id!("Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS");

#[program]
pub mod myanc {
    use super::*;

    pub fn initialize(_ctx: Context<Initialize>, mint: Pubkey) -> Result<()> {
        // msg!("{}", &mint);
        let m = find_metadata_account(&mint);
        let mS = m.try_to_vec().unwrap();
        msg!("{:?}", &mS);
        Ok(())
    }
}

#[derive(Accounts)]
pub struct Initialize {}

myanc.ts:

import * as anchor from "@project-serum/anchor";
import { Program } from "@project-serum/anchor";
import { Myanc } from "../target/types/myanc";
import { Metaplex, keypairIdentity, bundlrStorage, toBigNumber } from "@metaplex-foundation/js";
import { Connection, clusterApiUrl, Keypair, PublicKey, LAMPORTS_PER_SOL } from "@solana/web3.js";

describe("myanc", () => {
  anchor.setProvider(anchor.AnchorProvider.env());

  const program = anchor.workspace.Myanc as Program<Myanc>;

  it("Is initialized!", async () => {
    const mint = new PublicKey("XtBt31GCF5enFg7YG1YkH33Y5w1SruGMcz7GttUVUpH");

    const tx = await program.methods
      .initialize(mint)
      .rpc();
    // console.log("Your transaction signature", tx);
  });
});

Cargo.toml:

[package]
name = "myanc"
version = "0.1.0"
description = "Created with Anchor"
edition = "2021"

[lib]
crate-type = ["cdylib", "lib"]
name = "myanc"

[features]
no-entrypoint = []
no-idl = []
no-log-ix-name = []
cpi = ["no-entrypoint"]
default = []

[dependencies]
anchor-lang = "0.25.0"
mpl-token-metadata = "1.3.3"
solana-program = "~1.10.29"

原因

前提として、 Cargo.toml で、mpl-token-metadata は solana-program を記述している。
推測になるが、 mpl-token-metadata は内部で solana-program も利用しているため、それが競合してしまっているものと思われる。

対応

no-entrtypointを追記する。

具体的には「mpl-token-metadata = { version = "1.3.3", features = ["no-entrypoint"] }」を追記。

Cargo.toml:

[package]
name = "myanc"
version = "0.1.0"
description = "Created with Anchor"
edition = "2021"

[lib]
crate-type = ["cdylib", "lib"]
name = "myanc"

[features]
no-entrypoint = []
no-idl = []
no-log-ix-name = []
cpi = ["no-entrypoint"]
default = []

[dependencies]
anchor-lang = "0.25.0"
# mpl-token-metadata = "1.3.3"
mpl-token-metadata = { version = "1.3.3", features = ["no-entrypoint"] }
solana-program = "~1.10.29"