Conditional compile and user defined attributes

I want to use conditional compilation, and I imagined from the document,

const A: i32 = 1;
const A: i32 = 2;

How can I define "foo"? I could not understand the former "foo" is built-in or user-defined.

Configuration tokens are defined via --cfg [SPEC] argument for rustc. In case of cargo, you need to use build script: Page Moved
In particular, cargo:rust-cfg=[SPEC].

Contains example build script and its use in code. In particular, contains custom config flag stack_grows_up

I see.
So there are no ways to define configuration tokens in source code.
Is my understanding right?

Thank you for telling me information!

Yes. You can only define them outside. Pretty much logical to me. Otherwise you'd happen directly in C defines hell.