@@ -42,8 +42,8 @@ type EntryVisitor = vt<@mut EntryContext>;
42
42
pub fn find_entry_point ( session : Session , crate : @crate , ast_map : ast_map:: map ) {
43
43
44
44
// FIXME #4404 android JNI hacks
45
- if * session. building_library ||
46
- session. targ_cfg . os = = session:: os_android {
45
+ if * session. building_library &&
46
+ session. targ_cfg . os ! = session:: os_android {
47
47
// No need to find a main function
48
48
return ;
49
49
}
@@ -127,18 +127,24 @@ fn configure_main(ctxt: @mut EntryContext) {
127
127
* this. session . entry_fn = this. main_fn ;
128
128
* this. session . entry_type = Some ( session:: EntryMain ) ;
129
129
} else {
130
- // No main function
131
- this. session . err ( ~"main function not found") ;
132
- if !this. non_main_fns . is_empty ( ) {
133
- // There were some functions named 'main' though. Try to give the user a hint.
134
- this. session . note ( ~"the main function must be defined at the crate level \
135
- but you have one or more functions named ' main' that are not \
136
- defined at the crate level. Either move the definition or attach \
137
- the `#[ main] ` attribute to override this behavior. ") ;
138
- for this. non_main_fns. each |& ( _, span) | {
139
- this. session . span_note ( span, ~"here is a function named ' main' ") ;
130
+ if !* this. session . building_library {
131
+ // No main function
132
+ this. session . err ( ~"main function not found") ;
133
+ if !this. non_main_fns . is_empty ( ) {
134
+ // There were some functions named 'main' though. Try to give the user a hint.
135
+ this. session . note ( ~"the main function must be defined at the crate level \
136
+ but you have one or more functions named ' main' that are not \
137
+ defined at the crate level. Either move the definition or \
138
+ attach the `#[ main] ` attribute to override this behavior. ") ;
139
+ for this. non_main_fns. each |& ( _, span) | {
140
+ this. session . span_note ( span, ~"here is a function named ' main' ") ;
141
+ }
140
142
}
143
+ this. session . abort_if_errors ( ) ;
144
+ } else {
145
+ // If we *are* building a library, then we're on android where we still might
146
+ // optionally want to translate main $4404
147
+ assert ! ( this. session. targ_cfg. os == session:: os_android) ;
141
148
}
142
- this. session . abort_if_errors ( ) ;
143
149
}
144
150
}
0 commit comments